CSS Generators

CSS Specificity

All tools

Compare selector weights in seconds and stop guessing why a style is overridden.

How it works

Four simple steps

1

Paste selectors

Enter one selector per line, or start from the sample.

2

Read each tuple

See ids, classes and elements counted for every line.

3

Compare left to right

The higher first differing number decides the winner.

4

Copy the scores

Copy or download the list for a code review note.

CSS Specificity

About CSS Specificity

Your new .button-primary color loses to an old rule somewhere in the theme, and DevTools shows it crossed out. You have three candidate selectors and want to know which one is heavier. Paste them in and compare the scores.

Enter one selector per line. For each, the calculator counts ids, then classes, attribute selectors and pseudo-classes, then element names, and prints the tuple next to the selector along with a single combined number. The combined number is a convenience only: compare tuples from left to right, where any id outweighs any number of classes, and any class outweighs any number of elements.

The counting is a quick pattern match rather than a full selector parser, so a few cases need care. Pseudo-elements such as ::before are counted in the class column, although the specification puts them with elements. :not() is counted as a pseudo-class plus whatever is inside it, while the specification counts only its argument, and :where() should count as zero. When two selectors are equal, the one that appears later in the stylesheet wins, which this tool cannot see. If the conflict is between Tailwind utilities, the Tailwind class conflict checker explains it better, and the design system diff lab also lists @layer names, which outrank specificity altogether.

Scores update as you type.

Keyboard shortcut

Ctrl Enter - Run tool
FAQ

Frequently asked questions

See all FAQs

Answers for this tool. For site-wide help, open the FAQ hub.

Specificity is not a base-10 number. Each column is compared separately, and the id column is checked first. The combined figure in the output is only a quick reference.

No. Inline styles beat any selector, and !important declarations sit above normal ones regardless of specificity. The calculator only scores selector text.

Treat them with care. This calculator counts ::before as a class-level item and counts :not itself as a pseudo-class, so both read slightly higher than the specification would give.

View more FAQs

Related tools

View all

Tailwind Class Sorter

Sort Tailwind classes and detect conflicting utilities with a winner explanation.

Open

Design System Diff Lab

Diff design tokens and inspect CSS @layer order and selector specificity locally.

Open

SVG Path Inspector

Parse SVG path commands, preview on canvas, round and minify coordinates.

Open

Flexbox Generator

Build flex layouts visually.

Open

Explore 321 free tools

Everything you need as a developer, marketer or creator - in one beautiful place.

Browse all tools