Skip to main content

Free CSS Specificity Calculator Online

CSS Specificity Calculator computes the specificity triple (A,B,C) for any selector, counting IDs, classes, and elements, and correctly handles :where(), :is(), :not(), and :has().

Written & reviewed by Helperzy Editorial Team · Updated July 2026

CSS Selector

Specificity (A, B, C)

(1, 1, 1)

A = IDs · B = classes, attributes, pseudo-classes · C = elements, pseudo-elements

Token Breakdown

TokenTypeColumnPoints
#navID selectorA+1
.itemClass selectorB+1
liType / element selectorC+1

Don't collapse (A, B, C) into one number

Columns are compared independently. Eleven classes (0, 11, 0) never beat one ID (1, 0, 0).

Notes

:where() always contributes 0 specificity.

:is(), :not() and :has() take the specificity of their most specific argument.

Inline style attributes conceptually sit above at (1, 0, 0, 0).

!important overrides the normal cascade entirely and is not part of the specificity tuple.

100% Private

Everything runs locally in your browser. Nothing is uploaded.

How to Use CSS Specificity Calculator

1

Enter Your CSS Selector

Paste any selector, from a simple class to a complex chain that mixes IDs, attributes, pseudo-classes, and functional pseudo-classes like where, is, not, and has, into the input field.

2

Read the Specificity Triple

The calculator parses the selector and reports the A, B, C triple, counting IDs, then classes and pseudo-classes, then elements and pseudo-elements, while applying the special rules for the functional pseudo-classes correctly.

3

Compare and Refine

Enter a second selector to compare triples column by column, or adjust your selector to raise or lower its specificity so it wins or yields in the cascade exactly as you intend.

Calculate CSS Specificity for Any Selector Correctly

When two CSS rules target the same element and set the same property, the browser has to decide which one wins, and specificity is the mechanism it uses before falling back to source order. Specificity is not a single number but a triple, usually written as three values in the form A, B, C. The A column counts ID selectors, the B column counts classes, attribute selectors, and pseudo-classes, and the C column counts element type selectors and pseudo-elements. The columns are compared from left to right, so any selector with a higher A beats every selector with a lower A regardless of the other columns, exactly like comparing version numbers. This calculator parses a selector and reports that triple, and just as importantly it handles the modern functional pseudo-classes whose specificity rules trip up almost everyone. The counting rules are precise, and the functional pseudo-classes are where the subtlety lives. The universal selector and combinators such as the child, descendant, and sibling combinators contribute nothing to specificity — they are structural and count as zero across all three columns. The where pseudo-class is the special one: it always contributes zero specificity no matter what you put inside it, which is what makes it perfect for low-priority defaults that are easy to override. By contrast the is, not, and has pseudo-classes take on the specificity of their single most specific argument. So a not containing an ID contributes to the A column, while a not containing only an element contributes to the C column. This calculator applies each of these rules while parsing, so a selector mixing an ID, a couple of classes, and an element resolves to the correct triple rather than a naive count that ignores the functional wrappers. Two worked examples make the rules tangible. Consider the selector that combines an ID, a class, and an element type — an ID selector, then a descendant class selector, then a descendant element. It has one ID, one class, and one element, so the triple is one, one, one. Now consider a selector built from the is pseudo-class wrapping two alternatives, one of which is an ID and the other a plain element. Because is adopts the specificity of its most specific argument, and an ID outweighs an element, the whole thing resolves to one, zero, zero — the ID dominates and the element inside the is contributes nothing extra. Swap that is for a where wrapping the same arguments and the triple collapses to zero, zero, zero, because where is defined to contribute nothing regardless of its contents. Seeing these side by side is the fastest way to understand why where has become the recommended tool for authoring overridable base styles. The practical uses are all about diagnosing the cascade. A developer whose style is not applying can paste both the winning selector and their own selector, compare the triples, and immediately see that the other rule has a higher A or B column. Someone building a design system can verify that their base layer uses low-specificity selectors, ideally wrapped in where, so that component and utility styles override them without a specificity war. A person refactoring a large stylesheet can check whether replacing an ID selector with a class will change which rules win. And anyone learning CSS can build intuition by trying selectors and watching how adding an ID, a class, or a functional pseudo-class shifts the triple, which is far more effective than memorizing the rules from a table. A few tips keep specificity manageable. Do not collapse the triple into a single base-ten number by treating the columns as digits; the columns do not carry, so eleven classes never equal one ID, and pretending they do leads to wrong conclusions. Reach for the where pseudo-class when you want a rule that is easy to override, and avoid ID selectors in reusable component styles because their high A column makes them hard to beat without another ID. Remember that inline styles and the important flag sit outside the ordinary triple and override it, so if a rule still will not apply after you have matched specificity, check for those. Finally, when two selectors have identical specificity, the later one in source order wins, so ordering still matters after specificity is tied. Because this calculator runs entirely in your browser, you can test as many selectors as you like with no signup and nothing leaving your device.

CSS Specificity Calculator Formula & Method

Specificity = (A,B,C): A = count of #id selectors; B = count of .class, [attr], and :pseudo-class; C = count of element types and ::pseudo-elements. :where() = 0; :is()/:not()/:has() = specificity of most specific argument; * and combinators = 0. Compare A, then B, then C.

Examples: CSS Specificity Calculator

Input

#nav .item li

Result

(1, 1, 1)

One ID (#nav), one class (.item), and one element (li) each add to their own column, giving the triple one, one, one.

Input

:is(#header, p)

Result

(1, 0, 0)

The :is() pseudo-class adopts the specificity of its most specific argument, and the ID #header outweighs the element p, so the result is one, zero, zero.

Frequently Asked Questions – CSS Specificity Calculator

Specificity is a triple written as A, B, C. The A column counts ID selectors, the B column counts classes, attribute selectors, and pseudo-classes, and the C column counts element types and pseudo-elements. The columns are compared left to right, so a higher A beats any lower A regardless of the other columns. The calculator parses your selector and reports this triple directly.