CSS Specificity Calculator
Score CSS selectors as IDs, classes and elements, and see which of a list wins. Handles :is(), :not(), :where() and pseudo-elements.
How to check CSS specificity
Paste your selectors
One per line.
Read the scores
Each gets three numbers: IDs, then classes, attributes and pseudo-classes, then elements.
See which wins
The highest score is named. A higher first number always wins.
Functions such as :is(), :not() and :where() are handled.
Worked example
This is what CSS Specificity Calculator gives for its own sample values. Open the tool above and change anything to try your own.
Selectors, one per line
a .card .title #nav > li.active a:hover ul li:not(.last)::before :where(.a, #b) p
| Selector | IDs | Classes | Elements | Specificity |
|---|---|---|---|---|
| a | 0 | 0 | 1 | 0,0,1 |
| .card .title | 0 | 2 | 0 | 0,2,0 |
| #nav > li.active a:hover | 1 | 2 | 2 | 1,2,2 |
| ul li:not(.last)::before | 0 | 1 | 3 | 0,1,3 |
| :where(.a, #b) p | 0 | 0 | 1 | 0,0,1 |
About CSS Specificity Calculator
Score CSS selectors as three numbers: IDs, then classes, attributes and pseudo-classes, then elements and pseudo-elements. A higher first number always wins. Functions such as :is(), :not() and :where() are handled.
FAQs
What happens in a tie?
The rule that comes later in the stylesheet wins.
What does :where() do to specificity?
Nothing: it always counts as zero, which makes it useful for easy-to-override defaults.
Does !important change it?
It overrides specificity entirely, which is why it is best avoided.