Interactive tool

Work out which CSS rule actually wins

Enter two selectors and see which one the browser applies, with the specificity worked out for each. Selectors built from :is() or :where() can throw the count off, so treat the result as a starting point, not a verdict.

How-To Guide

CSS Specificity Calculator: work out which selector actually wins

A CSS Specificity Calculator breaks a selector down into its ID, class and element weight and shows how it ranks against another selector fighting for the same property. This is for anyone who has added a style, watched nothing change, and gone hunting through the stylesheet for whatever is overriding it. Once you can read the score, you can spot a conflict before you write the selector.

Level: Intermediate
Best for: Designers and developers debugging CSS style conflicts
CSS Specificity Calculator interface comparing two selectors by ID, class and element weight
  1. Enter the selectors in question

    Paste in the two or more selectors competing for the same element, exactly as they appear in the stylesheet.

  2. Read the specificity breakdown

    Check the ID, class and element counts for each selector, since the highest ID count wins regardless of how many classes or elements sit below it.

  3. Work out why a rule is losing

    Use the ranking to decide whether to raise the specificity of the selector, remove the rule that's blocking it, or reorder the rules instead, since a later rule of equal specificity or an !important declaration can still override the calculation.

CSS Specificity Calculator

Paste two CSS selectors below to see exactly how their specificity is calculated, and which one would win in a cascade conflict. Counts update as you type.

Selectors to compare

Example: #nav ul li.active > a:hover

Breakdown

Result

Specificity is shown as three numbers: IDs, then classes/attributes/pseudo-classes, then elements/pseudo-elements. A higher number in an earlier position always wins, no matter how many lower-priority selectors are added. If both selectors are identical in specificity, the one that appears later in the stylesheet wins, and an !important declaration overrides normal specificity rules entirely.

Free Tools

Find out which CSS rule actually wins

Two selectors can point at the same element, and the browser has to pick one. This works out the specificity score for each side of that clash and tells you which rule actually wins, so you can stop reaching for !important to force a fix. It's built for debugging a stylesheet you already know your way around.

No account needed · works on any device · free