Toolstia / CSS specificity calculator

CSS specificity calculator

Paste one or more CSS selectors and see their specificity as IDs, classes and elements. When you enter several, the one that wins is highlighted.

Specificity is written as IDs, classes, elements. A higher number in an earlier column always wins, so one ID beats any number of classes. :where() adds nothing, while :is(), :not() and :has() take their most specific item. Inline styles and !important sit above all of this.

How it works

  1. Paste your selectors, separated by commas or lines.
  2. Read the three numbers for each.
  3. See which selector wins.

How it is counted

Each ID adds to the first number. Each class, attribute selector and pseudo-class adds to the second. Each element and pseudo-element adds to the third.

Comparing

Compare left to right. One ID beats any number of classes, and one class beats any number of elements.

Modern selectors

:where() adds nothing. :is(), :not() and :has() count as their most specific argument. The *, combinators and :root special cases follow the CSS specification.

Beyond specificity

Inline styles, !important, cascade layers and source order also decide which rule applies.

Questions

Why is my style not applying?

A more specific selector elsewhere may override it. Compare both here.

Does :nth-child count extra?

It counts as one class, plus the most specific selector inside its "of" part if there is one.

Is my CSS stored?

Everything happens in your browser, and nothing you enter is sent anywhere.