📋 CSS Specificity Calculator

Estimate ID, class, and element specificity for common CSS selectors. Runs in your browser.

Last updated: November 8, 2026 · By the BoltQuickTools team

Paste one selector per line. The calculator follows the usual ID, class, and element specificity tiers.
0 selectors checked

Working out why one CSS rule beats another

When a style refuses to apply and DevTools shows it crossed out, the winning rule usually has higher specificity. This page scores a list of selectors so you can compare them side by side.

How to score selectors

Paste one selector per line into CSS Selectors. Specificity Results fills in as you type, and Calculate does the same thing on demand. Load Sample gives you four examples, Copy CSV copies the scores with a selector,ids,classes,elements header, and Clear empties both boxes.

Each score is three numbers: IDs, then classes, attributes and pseudo-classes, then elements and pseudo-elements. Compare from the left. One ID beats any number of classes.

Scores from the sample

#main .card:hover > a.icon::before -> (1,3,2)
.btn.primary -> (0,2,0)
body #app section[data-active="true"] -> (1,1,2)
#nav ul li a -> (1,0,3)

All of those are correct. #main .card:hover > a.icon::before beats #nav ul li a because the first numbers tie at 1 and the second column is 3 against 0. The > combinator and the universal * add nothing.

Selectors it scores incorrectly

The scoring is a set of pattern counts and does not fully follow the specification for newer pseudo-classes. Check any selector using these by hand:

SelectorTool showsCorrectWhy
a:not(.x)(0,2,1)(0,1,1):not() adds only its argument's weight, but the tool also counts :not itself
a:not(div)(0,1,1)(0,0,2)The element inside should count as an element
:is(#a, .b) p(1,2,1)(1,0,1):is() takes the weight of its most specific argument only
:where(.a) p(0,2,1)(0,0,1):where() always adds zero
li::marker(0,1,2)(0,0,2)Only before, after, first-line and first-letter are recognised as pseudo-elements alone. Others, including ::selection and ::placeholder, also count as a class
.md\:flex(0,2,0)(0,1,0)The escaped colon in utility class names is read as a pseudo-class

Other limits

Ties, lowering weight and attributes

My two selectors score the same. Which one wins?

The one that appears later in the stylesheet, assuming they are in the same cascade layer and neither is marked !important.

How do I lower a selector's weight without rewriting my HTML?

Wrap the heavy part in :where(), which adds nothing. Just remember this tool will over-count that version, as shown in the table above. The CSS selectors reference lists what each selector does.

Do attribute values change the score?

No. [data-active="true"] and [data-active] both count once in the middle column. Quoted text is stripped before counting, so a . or # inside quotes is not mistaken for a class or ID.

Does minifying affect specificity?

It should not, but the CSS minifier here can alter selectors in some cases, such as removing the space in .nav :first-child. That example keeps the same score but matches different elements, so compare the selectors as well as the numbers.