CSS Specificity Calculator
Developer Tools · Added
Paste a selector and see its specificity as the three numbers the cascade actually compares. Paste several and the tool marks the winner — including the case where two tie and source order decides. The breakdown names every part and says which column it counted in.
How to use the css specificity calculator
- 1Paste one selector, or several separated by commas or line breaks.
- 2Read the A-B-C triple: IDs, then class-level selectors, then type-level ones.
- 3Check the breakdown table to see which part of the selector produced which number.
- 4With more than one selector, look for the highlighted winner — or the note that says they tie.
Examples
A typical nested selector
- Input
- #header .nav li a:hover
- Result
- 1-2-2 — one ID, one class and one pseudo-class, two type selectors
:where costs nothing
- Input
- :where(#title) span
- Result
- 0-0-1 — the ID inside :where contributes nothing, leaving only the span
The same selector with :is instead would be 1-0-1.
About the css specificity calculator
The number that fixes today's bug and causes next month's
The quickest way to make a stubborn rule apply is to make its selector more specific — add the parent ID, add another class, reach for !important. It works immediately, and it raises the floor for every rule that comes after: the next person who needs to override your rule has to be more specific still.
This is how a stylesheet ends up with selectors five levels deep and a scattering of important declarations. Knowing the actual triple is what lets you make the smallest change that wins rather than the largest one you can think of.
Keeping specificity flat on purpose
Modern CSS gives you tools for this. Cascade layers let you declare that one group of rules always loses to another regardless of specificity. The :where pseudo-class lets you match broadly at zero cost, so resets and defaults do not have to be fought.
Where neither is available, a naming convention that keeps most selectors to a single class does the same job by discipline: if nearly everything is 0-1-0, then the ordinary way to override something is to write a rule after it, which is the behaviour most people expect in the first place.
Frequently asked questions
Why three numbers instead of one?
How do :is, :not, :has and :where count?
Where do !important and inline styles fit in?
Two of my selectors show the same triple. Which applies?
Related tools
CSS Formatter
Developer Tools
Format CSS with consistent indentation, or minify it for delivery.
CSS Grid Generator
Developer Tools
Build a grid visually — tracks, gaps, alignment and cell spans — and copy the CSS it produces.
Color Contrast Checker
Developer Tools
Check any two colours against the WCAG contrast thresholds, with passing shades suggested.