web/why-is-my-css-ignored-specificity-scored-with-three-numbers.md

Why is my CSS ignored? Specificity, scored with three numbers

The web · 4 min read ·

You write `p { color: red; }`, reload, and the text stays blue. The rule is fine: two rules are competing, and yours lost the contest.

The tie-breaker is called specificity, a score of three numbers (IDs, classes, element names) compared left to right. Edit three live selectors in a tiny page, watch the scores change, and see which rule the real browser picks.

A dark card listing three CSS selectors with their specificity scores; the ID selector #note scores 1-0-0 and is highlighted as the winner.

$ ls web/

see all →