CSS Specificity Calculator
calculate and compare CSS selector specificity scores
By Bikram NathLast updated
Specificity determines which CSS rule wins when two selectors target the same element, scored as an (a, b, c) triple where a is ID count, b is class and pseudo-class count, and c is element count. Paste `#header a` and `.nav .link` into the calculator and you get (1, 0, 1) versus (0, 2, 0) instantly. Unlike DevTools, it lets you compare hypothetical selectors before touching your stylesheet.
Try it now — free, instant, no signup
What is CSS Specificity Calculator?
CSS Specificity Calculator takes a selector string and returns its (a, b, c) triple. In that tuple, a counts ID selectors, b counts classes and pseudo-classes, and c counts element and pseudo-element selectors. Type `nav ul li.active > a` and you get (0, 1, 4). Enter `#sidebar .widget a` and you see (1, 1, 1), which wins because a=1 outranks any b or c value regardless of how many classes accumulate in the losing selector.
Browser DevTools shows which declaration is winning in the computed panel but does not expose raw specificity numbers or let you test selectors you have not written yet. Keegan Street's specificity.keegan.st is the closest dedicated alternative and adds a visual fish-scale chart. Firefox DevTools also annotates specificity inline when you hover over a rule in the inspector. This calculator is faster when you only need the numeric triple without navigating DevTools panels or loading another tab.
A common trap is treating specificity as arithmetic. Eleven class selectors score (0, 11, 0), which still loses to a single ID selector at (1, 0, 0) because columns compare left to right and never carry over. CSS Selectors Level 4 also changed pseudo-class behavior in ways that trip up developers: `:where()` contributes zero specificity regardless of what is inside it, while `:is()` takes the specificity of its most specific argument, so `:is(div, #id)` scores (1, 0, 0) even on a plain element.