CSS Specificity Calculator screenshot

CSS Specificity Calculator

Calculate a selector's specificity as (ids, classes, elements), with :where() adding nothing and :is(), :not() and :has() adding their highest argument.

Privacy First
0 Runs
Updated 2026-11-17
Runs in your browser
No sign-up, no upload

What the CSS Specificity Calculator does

The calculator walks the selector: #id adds to the id column, .class, [attr] and a pseudo-class add to the class column, and a type selector or ::pseudo-element adds to the element column. A functional pseudo-class is special — it recurses into its arguments and takes the maximum, never the sum.

Each line prints the triple and a decimal form (1, 3, 1 = 131) so two selectors can be compared at a glance, and the highest selector is named at the end.

Specificity is only one of the things that decides which declaration wins: source order, importance and layers all outrank it. An unbalanced parenthesis is refused with its position, because a selector the page cannot parse is not a selector it should guess at.

How to use it

Paste the selectors into the Selector list box, one list separated by commas, or press Run with the example already there.

Read the Specificity report below: one line per selector with its (ids, classes, elements) triple and decimal form.

Compare two selectors in the Specificity report that compete — the Highest line names the winner, and a tie tells you source order decides.

Worked example

Input:

#app .card:hover > a[href], :is(#a, .b) .c, :where(#x) li

Output:

#app .card:hover > a[href] → (1, 3, 1) = 131
:is(#a, .b) .c → (1, 1, 0) = 110
:where(#x) li → (0, 0, 1) = 1

Highest: #app .card:hover > a[href]
Counted as (ids, classes, elements). :where() adds nothing; :is(), :not() and :has() add the highest of their arguments.

Why it runs in your browser

The result is produced on this page with JavaScript, so it works offline after the page loads and nothing you enter is sent anywhere.

A real specificity count for every selector you paste: ids, classes and elements, computed from the selector's structure rather than from its characters.

`:where()` is counted as zero and `:is()`, `:not()` and `:has()` contribute the highest of their arguments, which is the rule in Selectors Level 4.

What it does, and what it does not

The calculator walks the selector: `#id` adds to the id column, `.class`, `[attr]` and a pseudo-class add to the class column, and a type selector or `::pseudo-element` adds to the element column. A functional pseudo-class is special — it recurses into its arguments and takes the maximum, never the sum.

Each line prints the triple and a decimal form (`1, 3, 1 = 131`) so two selectors can be compared at a glance, and the highest selector is named at the end.

Specificity is only one of the things that decides which declaration wins: source order, importance and layers all outrank it. An unbalanced parenthesis is refused with its position, because a selector the page cannot parse is not a selector it should guess at.

How to use CSS Specificity Calculator

Paste the selectors into the Selector list box, one list separated by commas, or press Run with the example already there.

Read the Specificity report below: one line per selector with its (ids, classes, elements) triple and decimal form.

Compare two selectors in the Specificity report that compete — the Highest line names the winner, and a tie tells you source order decides.

What to Expect

Best for

  • Settling an argument about which rule wins
  • Checking what `:is()` contributes to a selector

Not ideal for

  • Deciding the cascade on its own, which also depends on order and layers
  • A selector you cannot parse, which is refused instead of scored

What this tool keeps

  • `:where()` at zero
  • The maximum, not the sum, of `:is()` arguments

What may need cleanup

  • A tie still needs the source order checked
  • A selector inside `@layer` may lose for a reason not shown here

Common errors

  • The page refuses it: unbalanced ( at position 4

Example use cases

  • Debugging why an override does not apply
  • Reviewing a selector for unnecessary weight

Sample input

Selector list: #app .card:hover > a[href], :is(#a, .b) .c, :where(#x) li

Sample output

Specificity report: #app .card:hover > a[href] → (1, 3, 1) = 131 …

Who this is for

  • Frontend developers fighting the cascade
  • Anyone reviewing CSS specificity in a pull request

Frequently asked questions

How much does `:is()` add?

The highest specificity among its arguments, not their sum. :is(#a, .b) adds one id, because that is the strongest argument it could match.

Why does `:where()` add nothing?

That is its purpose in Selectors Level 4: it lets you write a forgiving selector list with zero specificity, so a reset can be overridden without an id.

Does a pseudo-element count as an element?

Yes. ::before and ::after contribute to the element column, exactly like a type selector. A single colon before a known pseudo-element (:before) is read the same way.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.