Developer

CSS Specificity Calculator

Calculate CSS selector specificity and understand why a rule loses to another that looks less specific.

Need this built for your product?

We design, build & host secure software & APIs.

Talk to an engineer

How specificity is counted

A selector's specificity is three numbers: inline styles, then IDs, then classes, attributes and pseudo-classes, then elements and pseudo-elements. They are compared left to right, and a higher number in an earlier position wins regardless of the later ones. This is the crucial part: specificity is not a sum. A single ID beats any number of classes, because the comparison never reaches the class column.

Source order only breaks ties

When two selectors have identical specificity, the one declared later wins. That is why moving a rule to the bottom of a stylesheet sometimes fixes things and sometimes does nothing at all: it only helps when specificity is already equal.

The universal selector and combinators count for nothing

The asterisk, and the combinators for child, sibling and descendant, add zero specificity. A long descendant chain is not automatically more specific than a short one; only the compound selectors within it count.

Where and is are the useful modern tools

The where pseudo-class always contributes zero specificity, which makes it ideal for default styles that should be trivially overridable. The is pseudo-class takes the specificity of its most specific argument, so the two are not interchangeable. Using where for base layers is the cleanest way to avoid specificity escalation in a design system.

Important is not a specificity level

It sits outside the calculation entirely, overriding any specificity in the same origin. Its only real counter is another important declaration with higher specificity, which is how stylesheets end up with important on nearly everything. Treat any need for it as a signal that the selector strategy has failed, with the honest exception of overriding third-party CSS you do not control.

Cascade layers change the picture

Layers now take precedence over specificity: a rule in a later layer beats a more specific rule in an earlier one. That inverts the usual mental model and is the modern answer to specificity wars, letting a low-specificity rule in your overrides layer beat a framework's high-specificity selector without any important at all.

Frequently Asked Questions

Privacy & Security

All processing happens locally in your browser — nothing is uploaded.

Data: None
Client-side-Side
Active
v1.0

How to Use

Paste a CSS selector to see its specificity breakdown and total score.

Disclaimer: This tool is provided "as is" without warranty of any kind. Results are for educational and utility purposes.