CSS Specificity Calculator

Score CSS selectors as IDs, classes and elements, and see which of a list wins. Handles :is(), :not(), :where() and pseudo-elements.

Processed on your device. Files are not uploaded

How to check CSS specificity

  1. Paste your selectors

    One per line.

  2. Read the scores

    Each gets three numbers: IDs, then classes, attributes and pseudo-classes, then elements.

  3. See which wins

    The highest score is named. A higher first number always wins.

    Functions such as :is(), :not() and :where() are handled.

Worked example

This is what CSS Specificity Calculator gives for its own sample values. Open the tool above and change anything to try your own.

Selectors, one per line

a
.card .title
#nav > li.active a:hover
ul li:not(.last)::before
:where(.a, #b) p
SelectorIDsClassesElementsSpecificity
a0010,0,1
.card .title0200,2,0
#nav > li.active a:hover1221,2,2
ul li:not(.last)::before0130,1,3
:where(.a, #b) p0010,0,1

About CSS Specificity Calculator

Score CSS selectors as three numbers: IDs, then classes, attributes and pseudo-classes, then elements and pseudo-elements. A higher first number always wins. Functions such as :is(), :not() and :where() are handled.

FAQs

What happens in a tie?

The rule that comes later in the stylesheet wins.

What does :where() do to specificity?

Nothing: it always counts as zero, which makes it useful for easy-to-override defaults.

Does !important change it?

It overrides specificity entirely, which is why it is best avoided.

Related tools