SolutionsCase StudiesAI ToolsResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/frontend-tools/css-specificity-calculator

CSS Specificity Calculator

ToolRuns in your browserNothing is uploadedFree · no sign-up

Paste one or more selectors, one per line, and see the specificity of each as three numbers: IDs, classes and types. Selectors are ranked so you can see which rule wins, with correct handling of :is(), :not(), :has(), :where() and pseudo-elements.

Using the CSS Specificity Calculator

How specificity works

When two rules set the same property on the same element, the browser picks the one with the higher specificity. Specificity is compared as three numbers: first the count of ID selectors, then classes, attributes and pseudo-classes, then type selectors and pseudo-elements. A single ID beats any number of classes.

The special pseudo-classes

:is(), :not() and :has() take the specificity of their most specific argument. :where() always counts as zero, which makes it perfect for low-priority base styles that are easy to override. The universal selector * and combinators add nothing.

Ties and order

If specificity is equal, the rule that appears later in the stylesheet wins. Inline styles beat all selectors, and !important beats normal declarations; cascade layers (@layer) are compared before specificity.

Keeping specificity low

Long chains and IDs make CSS hard to override later, which leads to more !important and more frustration. Prefer single class selectors, use :where() for resets, and organise priorities with cascade layers.

Debugging a rule that will not apply

When a style refuses to apply, open the browser developer tools, inspect the element and look for your rule crossed out. Paste your selector and the winning selector into this calculator to see why one beats the other, then lower the winner's specificity or wrap base styles in :where() rather than reaching for !important.

Frequently asked questions

Why does a selector with many classes lose to one with an ID?

Specificity is compared column by column, not added up. One ID in the first column outranks any number of classes in the second.

Do combinators like > and + count?

No, they add nothing to specificity.

Does it check my HTML?

No. It calculates specificity from the selectors alone.