Start a project

Tool 17 of 57 · CSS

CSS Specificity Calculator

Paste selectors or a stylesheet and see each one's specificity, ranked strongest first, so you know why a style isn't applying.

CSS Specificity Calculator at a glanceIllustration: 1, Selectors or CSS; 2, processed in your browser; 3, Ranked by weight.CSS Specificity Calculator</>1Selectors or CSS3Ranked by weight2In yourbrowser
1 Selectors or CSS 2 processed on your device 3 Ranked by weight

CSS Specificity Calculator

Selectors to compare

Paste selectors or a whole stylesheet: anything before a { on each rule is read.

Ranked, strongest first

#SelectorIDsClassesTypesSpecificity
Report

01

What it does

Scores and ranks CSS selectors so you can see which rule wins, including :is(), :not(), :has() and :where().

  • IDs, classes and types counted the way browsers do
  • :is(), :not() and :has() take their strongest argument
  • :where() counts as zero
  • Reads selectors straight from pasted CSS

02

Private by design

Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

03

What you get

A ranked table and a text report, with a Copy and a Download button on every result.

  • CSS
  • Selectors
  • Debugging

Why it matters

When a style refuses to apply, the cause is usually specificity: another rule with a stronger selector wins. Reaching for !important fixes it today and makes the next change harder.

Specificity has three parts (IDs, then classes, attributes and pseudo-classes, then elements and pseudo-elements), and newer pseudo-classes change the rules: :where() adds nothing, while :is() and :not() take their strongest argument. This calculator follows the Selectors Level 4 rules exactly.

How it works

  1. InputSelectors, or a whole stylesheet
  2. In your browserScored with the Selectors Level 4 rules
  3. OutputA ranked list, with ties and ID-heavy selectors flagged

Where it fits in a designer's workflow

  1. Plan
  2. Design
  3. Build
  4. Test
  5. Launch
Debugging why one rule beats another.

By the numbers

Specificity of example selectors (IDs, classes, elements)p: (0, 0, 1); .card p: (0, 1, 1); nav a:hover: (0, 1, 2); ul li::before: (0, 0, 3); :where(#main) .btn: (0, 1, 0); .btn.btn-primary: (0, 2, 0); #main .btn: (1, 1, 0); :is(#a, .b) p: (1, 0, 1)p(0, 0, 1).card p(0, 1, 1)nav a:hover(0, 1, 2)ul li::before(0, 0, 3):where(#main) .btn(0, 1, 0).btn.btn-primary(0, 2, 0)#main .btn(1, 1, 0):is(#a, .b) p(1, 0, 1)
Scored by this tool's own function. Compare left to right: one ID beats any number of classes, one class beats any number of elements. :where() always scores 0; :is() and :not() take their most specific argument. The bar length uses IDs × 100 + classes × 10 + elements just to draw it. Source: Selectors Level 4: specificity.
Show the numbers as a table
SelectorIDsClassesElements
p001
.card p011
nav a:hover012
ul li::before003
:where(#main) .btn010
.btn.btn-primary020
#main .btn110
:is(#a, .b) p101

How to use it

  1. Paste one selector per line, or a whole stylesheet.
  2. Read the table: the top row wins when both rules match the same element.
  3. Rows with the same score are ties: the later rule in the CSS wins.
  4. Download the report to share with your team.

FAQ

How is specificity written?

As three numbers, IDs, classes and types, such as (1, 2, 1). Compare from the left: one ID beats any number of classes.

Does inline style or !important count?

They sit outside specificity. An inline style beats any selector, and !important beats both, which is why it's best avoided.

Why does :where() count as zero?

It was designed for low-priority defaults that are easy to override, such as a CSS reset.

What about @layer?

Cascade layers are checked before specificity: a rule in a later layer wins even with a weaker selector. This tool compares selectors within the same layer.

Work with me

Want a site that gets these right?

I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

All developer tools · Back to leej.uk