Skip to content
⚖️

CSS Specificity Checker

See the exact specificity of every selector in your stylesheet, ranked so you can find out why a rule is not winning.

Runs in your browser

Updated

How specificity is counted

Each selector gets three numbers, read as a, b, c: a counts IDs, b counts classes, attributes and pseudo-classes, and c counts element names and pseudo-elements. The universal selector * counts nothing.

Compare left to right, so (1, 0, 0) always beats (0, 9, 9). The two rules that surprise people are handled correctly here: :is() and :not() take the specificity of their most specific argument, while :where() adds nothing at all.

How each selector gets scored

Every selector is measured with three counters. a counts ID selectors, b counts class selectors, attribute selectors and pseudo-classes, and c counts element names and pseudo-elements. A bare * adds nothing. Triples are compared left to right, so one ID outranks any number of classes.

The box decides its own reading mode: text containing no opening brace is measured as one selector, while text with a brace is parsed into a rule tree and yields a row per comma-separated selector, strongest first. Rows recompute 200 ms after you stop typing, and a rule nested inside an at-rule shows its context clipped to 28 characters.

A worked example

Load sample ranks seven rules. #main .btn leads at (1, 1, 0) in red, then .card .title a:hover at (0, 3, 1) in amber, then .card:where(#ignored) .title at (0, 2, 0), because :where() contributes nothing while :not() and :is() inherit their strongest argument. The last two rows, ul li:nth-child(2n) and div:not(.skip) > p, both land on (0, 1, 2), so the amber panel above the list names them as a tie.

What the ranking does not model

Specificity is one input to the cascade. The page counts selectors, not declarations, so a rule carrying !important reports the same triple it would without it, and an inline style attribute never reaches the parser at all. Cascade layers, which reorder winners without changing any triple, are equally invisible.

Where it stops

  • Inline styles and !important are not scored, so a rule can win in a browser yet sit lower here.
  • Source order and layer order are ignored; only identical triples are flagged.
  • A selector list pasted without braces is measured as one combined selector.
  • Single-colon pseudo-elements such as :before count as pseudo-classes, not elements.

Questions people ask

Why is my rule still losing?

When two rows share a triple, the rule written later in the file wins, which is what the tie panel is telling you to check.

Does :where() really cost nothing?

Yes, everything inside it is free, which is why reset styles use it. Pair this with css-validator to catch misspelled properties, and with z-index-manager when the conflict is stacking rather than specificity.