CSS Specificity Calculator
Calculate the specificity of CSS selectors following the Selectors Level 4 rules. Enter one selector or selector list per line and get the (ID, class, type) score of each selector, with :is(), :not() and :has() counted by their most specific argument, :where() counted as zero and nth-child of S handled. The most specific selector is named.
Frequently asked questions
How is specificity counted?
Each selector gets three numbers. The first counts ID selectors, the second counts classes, attribute selectors and pseudo-classes, and the third counts type selectors and pseudo-elements. Selectors are compared column by column from the left, so one ID beats any number of classes.
How are :is(), :not() and :has() counted?
They take the specificity of the most specific selector in their argument list, so :is(.a, #b) counts like an ID. :where() always counts as zero, which makes it useful for low-priority base styles.
What about :nth-child(2n of .item)?
:nth-child() and :nth-last-child() count as a pseudo-class, plus the most specific selector after of, as the Selectors Level 4 specification defines.
Are pseudo-elements counted like types?
Yes. ::before, ::after and the other pseudo-elements count in the third column, and so do the old single-colon forms :before, :after, :first-line and :first-letter.
Does the universal selector count?
No. *, combinators such as > and +, and the nesting selector & add nothing. A selector list separated by commas is split, and each selector is listed with its own specificity.
Do inline styles and !important appear here?
No. Inline style attributes and !important are not part of selector specificity. Inline styles win over any selector, and !important declarations are compared in a separate step of the cascade.