@TedJenkler
Posted
Class selectors style elements with a specific class attribute. They use a period (.) followed by the class name. CSS specificity determines which rules are applied when multiple rules could match the same element. The higher the specificity, the more important the CSS rule.
Hereβs the order of specificity from highest to lowest:
Inline Styles: Applied directly to the element. (Try to avoid using inline styles unless necessary for styled components.)
ID Selectors: Applied to elements with a specific ID. (Try to avoid using IDs for styling as much as possible due to high specificity.)
Class, Attribute, and Pseudo-class Selectors: Applied to elements with a specific class, attribute, or state (e.g., :hover). (Use these for most styling.)
Element and Pseudo-element Selectors: Applied to elements or parts of elements (e.g., p tag, ::before). (Use these for general styling.)
Hope this helps!
Best, Teodor
Marked as helpful