Specificity Flashcards
What determines which CSS rule is applied when there are competing declarations?
CSS uses specificity to decide between competing declarations.
What are the three components of the specificity triad?
The three components are A (id-like specificity), B (class-like specificity), and C (element-like specificity).
In CSS specificity, what does a higher value in component A signify?
A higher value in component A (id-like specificity) means the rule is more specific.
How are two specificity values compared when their first component is equal?
If the first components are equal, compare the next higher specificity value.
Which specificity is more specific: (1, 0, 0) or (0, 4, 3)?
(1, 0, 0) is more specific than (0, 4, 3).
How does specificity work in complex and compound selectors?
Each part of a complex or compound selector adds to the specificity.
What is the specificity of the selector a.my-class.another-class[href]?
The specificity is (0, 3, 1).
What role does element-like specificity (C) play in determining CSS specificity?
Element-like specificity (C) is the third component and is used when the first two components are equal.
How would a selector with an ID (e.g., #id) compare to a selector with only classes and elements (e.g., .class a) in specificity?
A selector with an ID (#id) is more specific than a selector with only classes and elements.
What happens when two specificity values are tied in the first and second components?
When the first and second components are tied, the comparison moves to the third component (element-like specificity).