CSS Specificity Calculator

Calculate CSS selector specificity. Compare ID, class, and type counts for a selector list, including :is(), :where(), :has(), and :nth-child().

CSS selectors

Separate selectors with commas.

Specificity comparison

Enter a selector or use the sample to see its specificity.

Calculate and compare CSS selectors

Paste a selector or a comma-separated list and read the weights side by side. Try #app .link, nav a:hover. The highest weight is marked when comparing multiple selectors. Equal highest weights are marked together.

Read the three specificity counts

The first count is for ID selectors, the second is for class selectors, attributes, and pseudo-classes, and the third is for type selectors and pseudo-elements. Compare the counts from left to right. For example, (1, 0, 0) outranks (0, 10, 0) because the first count differs. The universal selector * and combinators contribute zero.

Account for functional pseudo-classes

:where() contributes zero, including everything inside it. :is(), :not(), and :has() use the most specific selector in their argument list. :nth-child() and :nth-last-child() count the pseudo-class itself and add the highest specificity from an of list if one is present. For a nested selector such as & .link, replace & with the parent list inside :is(). For example, use :is(#app, .panel) .link for a rule nested under #app, .panel.

Put specificity in context

Specificity compares selectors for declarations with equal origin, importance, and cascade layer that match the same element. Scoping proximity and source order can break ties. Use your browser’s developer tools to see the entire cascade for an element, including inline styles.