Free Online CSS Specificity Calculator with Every Part Counted
Paste one selector or a list of them and read the real three number specificity, with every part of each selector labelled and counted. The awkward cases are handled properly: is, not and has take their heaviest argument, where is always zero, and an id inside an attribute selector is not an id.
Enjoying WizTools123? Help keep our server infrastructure 100% free and open for everyone.
How to Work Out CSS Specificity
A few steps, and nothing is uploaded.
What to Know About Specificity
Including where it sits in the cascade, which is lower than you think.
@layer loses to one in a later layer no matter how specific it is, and an unlayered rule beats every layered one. That is the whole point of layers: a third party stylesheet put in an early layer can use ids freely and still never override your own unlayered rules. If two rules seem to disagree with what this page tells you, check which layer each one is in before doubting the tuple.
:where() is zero, and :is(), :not() and :has() take their heaviest argument. :where(#a, .b) contributes nothing at all, which makes it the right tool for a low-specificity reset or a themeable component. :is(#a, .b) contributes 1,0,0, because the id is the most specific thing in the list, even when the element actually matched by the .b half. The functional pseudo-class itself never counts as a class; only its contents count.
& takes the specificity of the parent selector, which this page cannot know, so it is counted as zero and flagged. It also cannot tell you which rule won on your real page, because that depends on layers, origins and source order that live in your files rather than in the selector text.
Key Features & Capabilities
What this tool does, and what it deliberately does not.
About the CSS Specificity Calculator
Specificity is three numbers, and almost every explanation of it gets at least one detail wrong. The usual mistakes are treating the three numbers as digits of a single score, counting the universal selector or a combinator as something, assuming a pseudo-element counts as a class, and treating :is() or :not() as a pseudo-class in its own right. Each of those produces an answer that looks plausible and is wrong.
So this page counts each part separately and shows its working. The parser walks the selector character by character, handling nested parentheses and quoted attribute values, and labels every piece: this is an id, this is an attribute selector so it counts as a class, this is a combinator so it counts as nothing, this :where() is zero no matter what is inside it. The tuple at the top is then just the sum of the labelled parts, which makes the result checkable rather than magic.
The comparison is the part people actually want. Given two selectors the page says which one wins and, more usefully, which column decided it, because that tells you what to change. The cascade ladder further down exists because specificity is much lower in the order of decisions than its reputation suggests: origin and layer are settled before anyone looks at these three numbers at all.
Frequently Asked Questions
The tuple, the functional pseudo-classes, layers and important.
:not() itself counts for nothing, but its argument counts as if it were written normally, taking the most specific option if there is a list. So :not(.a) is 0,1,0 and :not(#a, .b) is 1,0,0. The same rule applies to :is() and :has(). Only :where() is different: it is always zero, whatever is inside it.[id="main"] is 0,1,0 while #main is 1,0,0, even though both match exactly the same element. This is occasionally used on purpose to target an element by id without the specificity that comes with the hash form.style attribute is a separate, higher step of the cascade, so no selector can beat it on specificity alone, which is why people describe it as 1,0,0,0. !important is higher still and reverses the order of the origins, so an important declaration in a user stylesheet beats an important one in yours. Within one origin and layer, two important declarations are then compared by specificity as normal.!important, and check source order, which only decides a tie once the tuples are identical. This page counts the selector text and cannot see any of those.