All tools

CSS Specificity Calculator

CSS

Calculate and compare CSS selector specificity with token breakdown

Paste a selector like `.nav > ul li.active a` and get back the standard four-part specificity tuple (inline styles, IDs, classes/attributes/pseudo-classes, elements), or paste two competing selectors to see which one actually wins, which is often the real answer when a style mysteriously isn't applying and the cause turns out to be specificity rather than a missing `!important`. Modern selectors like `:where()` (zero specificity by design), `:is()`, `:not()`, and `:has()` are handled correctly, including the rule that `:is()`/`:not()`/`:has()` take on the specificity of their most specific argument rather than counting as one flat unit. The tool flags `!important` separately since it overrides specificity entirely regardless of score, and it expects fully-resolved CSS selectors, so Sass nesting or the `&` parent selector needs to be compiled to plain CSS first.

cssspecificityselectorcascade

How to use CSS Specificity Calculator

  • 1.Paste a CSS selector like `.nav > ul li.active a` to see its specificity broken down into ID, class, and element token counts.
  • 2.Paste two competing selectors side by side to figure out which one wins when both apply to the same element.
  • 3.Use it to debug a style that isn't applying — often the real cause is a higher-specificity selector elsewhere, not a missing `!important`.

Frequently asked questions

Does this account for `!important`?
The specificity score itself follows the standard CSS spec (inline, ID, class/attribute/pseudo-class, element), but `!important` overrides specificity entirely regardless of score — the tool flags this separately rather than folding it into the number.
Is my CSS sent to a server?
No, selectors are tokenized and scored entirely in your browser.
Does it support CSS nesting or `&` selectors?
It expects fully-resolved selectors as they'd appear in compiled CSS — if you're using Sass or native CSS nesting, resolve the selector first before pasting it in.
How are inline styles scored?
Inline styles (via the `style` attribute) outrank any selector-based specificity, which this tool notes but doesn't compute a selector for since there's no selector involved.

Availability

This tool currently runs in the browser only — no REST API, SDK, or MCP equivalent yet.