CSS Specificity Calculator

Enter any CSS selector to get the (A, B, C) specificity score with visual breakdown.

1
A — IDs
#nav
2
B — Classes / Attrs / Pseudo-classes
.item, :hover
1
C — Elements / Pseudo-elements
span
Specificity Score
1-2-1
Token Breakdown
ID
Class
Pseudo-class
Attribute
Element
Pseudo-element
Zero (*, combinators)
Compare Selectors

How CSS Specificity Works

Every CSS selector has a specificity score expressed as three numbers (A, B, C). When multiple rules target the same element and property, the rule with the highest specificity wins. The numbers are compared left to right — a higher A always beats a higher B or C.

Scoring Rules

Selector typeScoreExample
Inline style (style="")Always winsstyle="color:red"
ID selectorA+1#header
Class selectorB+1.active
Attribute selectorB+1[type="text"]
Pseudo-classB+1:hover, :nth-child(2)
Element / type selectorC+1div, span
Pseudo-elementC+1::before, ::after
Universal selector, combinators0*, >, +, ~

:is(), :not(), :has() take the specificity of their most specific argument. :where() always contributes zero specificity.