CSS Specificity Calculator
Calculate the (a, b, c) specificity score of any CSS selector. Compare multiple selectors and see which wins the cascade.
Color key:A — IDsB — Classes / attrs / pseudo-classesC — Elements / pseudo-elements
1IDs (A)
2Classes (B)
1Elements (C)
Score(1,2,1)= 121
#nav .item:hover > span
Breakdown
#navID selector+1 to A (IDs)(1,0,0).itemClass / attribute / pseudo-class+1 to B (Classes)(0,1,0):hoverClass / attribute / pseudo-class+1 to B (Classes)(0,1,0)spanElement / pseudo-element+1 to C (Elements)(0,0,1)Compare Selectors
Common Examples
How it works: Specificity is a weight applied to CSS declarations. The A column counts ID selectors (#id). B counts class selectors (.class), attribute selectors ([attr]), and pseudo-classes (:hover). C counts element type selectors (div, span) and pseudo-elements (::before). The universal selector * and combinators (+, >, ~, space) contribute nothing.Special rules:
:not(), :is(), and :has() take the specificity of their most specific argument. :where() always contributes zero specificity.