CSS Specificity Calculator
calculate and compare CSS selector specificity scores
Interactive CSS Specificity Calculator — coming soon
In development. We're still building the interactive CSS Specificity Calculator. The guide below explains exactly what it does and how to use it. In the meantime, here are DevLab tools that already work in your browser:
Browse all working tools →Specificity determines which CSS rule wins when two selectors target the same element, scored as an (a, b, c) triple where a is ID count, b is class and pseudo-class count, and c is element count. Paste #header a and .nav .link into the calculator and you get (1, 0, 1) versus (0, 2, 0) instantly. Unlike DevTools, it lets you compare hypothetical selectors before touching your stylesheet.
What is CSS Specificity Calculator?
CSS Specificity Calculator takes a selector string and returns its (a, b, c) triple. In that tuple, a counts ID selectors, b counts classes and pseudo-classes, and c counts element and pseudo-element selectors. Type nav ul li.active > a and you get (0, 1, 4). Enter #sidebar .widget a and you see (1, 1, 1), which wins because a=1 outranks any b or c value regardless of how many classes accumulate in the losing selector.
Browser DevTools shows which declaration is winning in the computed panel but does not expose raw specificity numbers or let you test selectors you have not written yet. Keegan Street's specificity.keegan.st is the closest dedicated alternative and adds a visual fish-scale chart. Firefox DevTools also annotates specificity inline when you hover over a rule in the inspector. This calculator is faster when you only need the numeric triple without navigating DevTools panels or loading another tab.
A common trap is treating specificity as arithmetic. Eleven class selectors score (0, 11, 0), which still loses to a single ID selector at (1, 0, 0) because columns compare left to right and never carry over. CSS Selectors Level 4 also changed pseudo-class behavior in ways that trip up developers: :where() contributes zero specificity regardless of what is inside it, while :is() takes the specificity of its most specific argument, so :is(div, #id) scores (1, 0, 0) even on a plain element.
When to use CSS Specificity Calculator
- Debug a crossed-out rule in DevTools by checking which competing selector holds the higher (a, b, c) score.
- Audit a legacy stylesheet to find selectors bloated with ID qualifiers before a component refactor.
- Compare the specificity cost of adding one class versus nesting one level deeper before writing any new CSS.
Frequently Asked Questions
Does !important override specificity, and will it appear in the (a, b, c) score?
Why does :not(.active) increase the specificity score if :not() looks like a neutral wrapper?
Do combinators and the universal selector affect the specificity score?
What is the specificity difference between :is() and :where(), and does the calculator treat them correctly?
Should I paste the full CSS rule block with properties, or just the selector?
Related Tools
- CSS Variables Cheatsheetcomplete CSS custom properties reference with examples · CSS
- CSS Flexbox Generatorgenerate CSS flexbox layouts with a visual editor · CSS
- CSS Grid Generatorgenerate CSS grid templates visually with live preview · CSS
- HTML Beautifierformat and indent HTML code with configurable settings · HTML