Skip to content
M2TOOLKIT

Developer · free tool

CSS Specificity Calculator

Find out why one CSS rule beats another.

Use it as often as you like — it's free, with no sign-up and no limits.

  • Developer
  • Free
  • No sign-up
  • Nothing is sent or stored
  • Updated
  1. 1#nav .menu > li:hover a122Wins
  2. 2:is(#main, .content) p::first-line102
  3. 3.btn.btn-primary020
  4. 4a:not(.external)011
  5. 5ul li a003
  6. 6:where(.card) h2001

Specificity is compared column by column: IDs, then classes / attributes / pseudo-classes, then elements / pseudo-elements. A tie goes to the rule that comes last. :where() adds nothing; :is(), :not() and :has() take their most specific argument. Inline styles and !important beat all of these. (1,2,2 is the highest here.)

The calculation happens instantly in your browser. The numbers you enter are not sent to our servers or saved.

How to use the CSS Specificity Calculator

  1. Paste selectors, one per line.
  2. Read each score as IDs, classes, elements.
  3. The list is ranked — the top selector wins.

What does this tool do?

When two rules target the same element, the one with higher specificity wins, compared column by column. This calculator follows Selectors Level 4: :where() counts zero, :is(), :not() and :has() take their most specific argument, and pseudo-elements count as elements. Inline styles and !important override specificity entirely.

Everything runs in your browser — nothing you paste is uploaded.

Why use it?

  • Selectors Level 4 rules.
  • Ranked results.
  • Handles selector lists.

Use cases

  • Debug why a CSS rule isn't applying.
  • Keep a stylesheet's specificity low and predictable.
  • Learn how :is(), :where() and :not() are scored.

Scores, highest first

Specificity is compared column by column, IDs first:

SelectorIDs, classes, elements
#nav .item a1, 1, 1
.btn.primary0, 2, 0
ul li:hover0, 1, 2
a::before0, 0, 2
:where(.card) p0, 0, 1

Common mistakes

  • Fixing conflicts with !important instead of simpler selectors.
  • Using IDs for styling, which are hard to override later.
  • Thinking that more classes always beat one ID — a single ID wins.

Privacy

The calculation happens instantly in your browser. The numbers you enter are not sent to our servers or saved. There's no account to create and nothing to install.

Frequently asked questions

What if two selectors have the same score?

The one that appears later in the CSS wins.

Why does :where() count zero?

It was designed for easily overridable defaults, so it adds no specificity.

Do inline styles have specificity?

They beat any selector, and only !important rules can override them.

Content last updated . See how M2Toolkit works.

Other tools people use alongside the css specificity calculator.