Specificity
noun
say it: “spes-ih-FIS-ih-tee” /ˌspɛsɪˈfɪsɪti/
A score the browser gives every selector, counting ids, then classes, attributes and pseudo-classes, then element names. When rules clash, the higher score wins.
What is specificity?
Specificity is how precise a selector is. When rules clash, the more specific one wins: an id beats a class, and a class beats a tag name.
p { color: black; }
.intro { color: blue; } /* wins over p: a class is more specific */
In a sentence
- “My .price rule lost because .product .price has higher specificity, even though mine came last.”
Level: Novice · More CSS terms at this level
Updated