Home/Tools/Utilities/Specificity Calculator
Utilities · Generator

Specificity Calculator

Calculate and understand CSS selector specificity scores.

CSS Specificity Calculator

Enter CSS selectors to calculate their specificity. Specificity determines which CSS rule is applied when multiple rules target the same element.

Specificity Explanation

Format: (ID, Class, Element)

!important: Overrides specificity

Inline styles: Have higher specificity than CSS rules

Higher specificity wins when rules conflict

Results

SelectorSpecificity
div(0,0,1)

Specificity Ranks

div(0,0,1)Rank: 1
Generated CSS & HTML
div {
  /* Specificity: 0,0,1 */
  /* Higher specificity wins in case of conflicts */
}
100%
Free, no
sign-up needed
0
Code written
by hand
85+
CSS tools
in one place
<1s
Copy-ready
CSS instantly
What is this

What is the CSS Specificity Calculator?

Calculate CSS selector specificity scores. Compare selectors to understand which rule wins and why. No more specificity guesswork.

Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.

How to use

Using the CSS Specificity Calculator

Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.

1

Enter your selector

Paste any CSS selector into the input. The calculator splits it into ID (a), class/attr/pseudo-class (b), and element/pseudo-element (c) components.

2

Compare multiple selectors

Add a second selector to compare. The higher specificity (a,b,c) wins. IDs beat any number of classes.

3

Read the result

The score is shown as (a,b,c). Higher a beats any b or c value regardless of count.

The output

What the generated code looks like

Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.

specificity-reference.css
/* Specificity: (a, b, c) where a=IDs, b=classes/attrs/pseudoclasses, c=elements */

/* (0,0,1) — one element */
h1 { }

/* (0,1,0) — one class */
.title { }

/* (0,1,1) — one class + one element */
h1.title { }

/* (1,0,0) — one ID */
#hero { }

/* (1,1,1) — one ID + one class + one element */
#hero .title h1 { }

/* (0,0,0) — :where() has zero specificity */
:where(.title) { }

/* !important overrides everything but creates technical debt */
.override { color: red !important; }
Common mistakes & fixes

Common mistakes & how to fix them

A few habits trip people up. Here is what to watch for — and the exact fix.

Using ID selectors for styling components

ID selectors (specificity 1,0,0) overpower all class selectors. Overriding them requires !important or another ID selector.

Fix: Reserve IDs for JavaScript hooks and anchor targets. Use classes for all styling. This keeps specificity manageable.

Overusing !important

!important overrides inline styles and all specificity. When multiple rules use !important, specificity applies among them, creating !important wars.

Fix: Use !important only for user-facing overrides (accessibility zoom stylesheets). In component CSS, use :is() or :where() to manage specificity deliberately.

Pro tips

Pro tips for better results

:is() and :not() use the specificity of their most specific argument

:is(#id, .class) has specificity (1,0,0) because the most specific argument is #id. :where() has zero specificity regardless of its contents, making it ideal for reset styles.

FAQ

Frequently asked questions

No. The universal selector *, combinators (+, ~, >), and the :where() pseudo-class all contribute zero specificity.
Other !important declarations with higher specificity. Inline styles with !important. User agent stylesheets with !important (rare). In practice, !important is very difficult to override, which is why it creates maintenance problems.

From the blog

Read more