CSS Specificity Calculator

Calculate CSS selector specificity (IDs, classes, elements) for one selector or a whole stylesheet, including :is(), :not(), :has() and :where(). Ranked list.

Calculator

Was this tool useful?

About this tool

About CSS Specificity Calculator

Why does one CSS rule win over another? Paste selectors – or a whole CSS file – and the calculator gives each one its specificity as (IDs, classes/attributes/pseudo-classes, elements/pseudo-elements), ranks them from strongest to weakest and explains how they compare. It follows Selectors Level 4: :is(), :not() and :has() take their strongest argument, :where() counts zero, :nth-child(… of S) adds S, and legacy pseudo-elements like :before count as elements.

How it works

Specificity (a, b, c): a = ID selectors, b = classes, attributes and pseudo-classes, c = type selectors and pseudo-elements. Compare a first, then b, then c. Inline styles and !important beat all selectors.

Example

#header .menu > li a:hover has specificity (1, 2, 2) and beats .btn.btn-primary (0, 2, 0) because of its ID.

How to use this tool

  1. Type selectors (one per line) or paste a stylesheet.
  2. Read the specificity of each selector.
  3. Use the ranking to fix rules that do not apply.

Frequently asked questions

Does order in the file matter?

Only when specificity is equal – then the rule that comes later wins.

How do I lower specificity?

Use classes instead of IDs, avoid long chains, and wrap selectors in :where() to make them zero.

Is my data uploaded?

No. Everything runs in your browser and stays on this device.

Is my design uploaded by the CSS Specificity Calculator?

No. The CSS Specificity Calculator works in your browser, so your images and colours stay on your device.