CSS Specificity Calculator
Computes the specificity of each CSS selector as an (a,b,c) triple and highlights the highest. Paste selectors one per line, as comma lists, or a full stylesheet.
Use the tool
Why this tool exists
When your CSS rule has no effect, the cause is almost always specificity: a more specific selector somewhere else is winning. Working it out means counting IDs, classes and element names in your head, and remembering that :not() and :is() take their most specific argument while :where() counts for nothing.
Paste your selectors and each one is scored as three numbers: IDs, then classes, attributes and pseudo-classes, then elements and pseudo-elements. The highest is marked. You can paste a whole stylesheet, and the tool pulls out the selectors for you. Note that it compares selector specificity only, not source order, cascade layers or !important, which can also decide a conflict. It runs in your browser.
How to use it
- Paste selectors, one per line, or a whole stylesheet.
- Read the (a,b,c) score in front of each selector.
- Look for the line marked as the highest.
- Adjust the selectors, then recheck.
Frequently asked questions
How is (a,b,c) read?
The first number counts ID selectors, the second counts classes, attributes and pseudo-classes, the third counts element types and pseudo-elements. Compare from left to right: any higher a beats any b, and so on.
How are :not, :is, :where and :has handled?
:not, :is, :matches and :has take the specificity of their most specific argument. :where adds nothing. nth-child pseudo-classes count as one class, plus any selector listed after "of".
Does the tool consider !important, inline styles or layers?
No. It scores selectors only. Inline styles, !important declarations, cascade layers and source order are applied separately by the browser and can override these results.
What does the highest marker mean?
It points at the selector with the greatest specificity in the list you pasted. If two are equal, the first one is shown, and in a real page the later rule in the source would win.