πŸ–ŒοΈ CSS Specificity Calculator β€” Selector Weight

Paste one selector to see its specificity tuple. IDs outweigh classes, and classes outweigh elements. :where() adds no weight; :is() and :not() use the most specific argument.

Design Free Β· no sign-up Reviewed 2026-11-03
Input
Result
Specificity

  
Breakdown

Private by design. This tool runs entirely in your browser β€” nothing you enter or add is uploaded to any server.

What this tool does

The specificity calculator scores a single CSS selector as a four-part tuple: inline styles, IDs, classes/attributes/pseudo-classes, and elements/pseudo-elements. Comparing tuples from left to right shows which rule wins when two selectors target the same element.

It understands modern pseudo-classes such as :where(), which contributes no specificity, and :is() and :not(), which take the specificity of their most specific argument. That makes it more useful than counting characters in the selector.

When to use it

  • Explaining why a component style is being overridden.
  • Choosing between an ID selector and a class-based approach.
  • Checking the effect of :is(), :not() and :where() on a selector's weight.
  • Reviewing a stylesheet for unnecessarily high specificity.

How it works

  1. Enter a single selector, not a full rule with braces.
  2. Press Calculate specificity. The tuple is inline styles, IDs, classes/attributes/pseudo-classes, then elements/pseudo-elements.
  3. Compare tuples left to right. A higher number in an earlier column wins.

Worked example

The selector #main .item scores (0,1,1,0): one ID and one class. The selector nav .menu > a:hover scores (0,0,2,2): one class for .menu, one pseudo-class for :hover, and two element selectors for nav and a. The first selector wins because its ID column is higher, regardless of the later columns.

  • #main .item scores (0, 1, 1, 0).
  • nav .menu > a:hover scores (0, 0, 2, 2) because :hover is a pseudo-class.
  • button scores (0, 0, 0, 1).

Accuracy and limitations

  • Enter one selector, not a full rule with declarations or braces. Selector lists are parsed separately and should be checked one at a time.
  • The score does not model cascade layers, !important, source order or inherited styles, which can override specificity in practice.
  • Inline style attributes are represented by the first tuple column only when the selector itself is written as inline style; a normal stylesheet selector cannot outrank an inline attribute.

Privacy and data handling

Selectors are parsed locally in the browser. No stylesheet or page content is uploaded.

Frequently asked questions

Does !important change the tuple?

No. !important is a separate cascade layer and is not part of the specificity tuple. Remove it from the selector before scoring.

How are :is() and :where() handled?

:where() contributes nothing. :is() and :not() contribute the highest specificity among their arguments, not the sum of every argument.

Are commas supported?

Enter one selector. If you paste a comma-separated list, only the first selector is scored and a note is shown.

Does :where() really add nothing?

Correct. :where() always contributes zero specificity, while :is() and :not() adopt the specificity of their most specific argument.

Why does my rule still lose with a higher tuple?

Check for !important, cascade layers, inline styles or a later rule with equal specificity. Specificity is only one part of the cascade.

More Design tools β†’