AscendLab

Developer tools

CSS 优先级计算

New free tool

CSS Specificity Calculator for Selectors

Compare selector weight when debugging the cascade, refactoring CSS, or reviewing design system overrides.

Quick answer

CSS specificity compares selector weights in ID, class-like, and element-like groups.

Higher scores usually win when competing rules apply to the same element.

Best inputs

Paste complete selectors

Include IDs, classes, attributes, pseudo-classes, and elements exactly as used in CSS.

Compare close matches

The tool is most useful when two selectors target the same component state.

CSS selectors
Paste one selector per line, or comma-separated selector lists.

Try a common specificity check

Specificity results
Scores use the common ID, class, element format.

Selectors

5

Strongest

1-1-1

Format

A-B-C

ScoreIDsClassesElementsSelector
1-1-1111#app .card > h2
0-3-0030.button.primary:hover
0-2-3023main article.post[data-state="published"] h1
0-1-2012:where(.shell) nav a[aria-current="page"]
0-1-1011:is(header, main, footer) .link
Example
Compare #app .button:hover with .card .button.primary to see which selector carries more cascade weight.
Assumption
Scores use the common A-B-C model: IDs, class-like selectors, and element-like selectors.
Limitation
Specificity is only one cascade factor. Source order, cascade layers, importance, inheritance, and shadow DOM can also matter.

Suggested workflow

CSS debugging workflow

Clean CSS, compare selector weight, then tune responsive values and colors.

Related tools

Related CSS tools

Frequently asked questions

What is CSS specificity?

CSS specificity is the weight browsers use to decide which selector wins when multiple rules target the same element.

What does 1-2-3 mean?

The score means 1 ID selector, 2 class-like selectors, and 3 element-like selectors.

Does this tool need a backend?

No. Selector parsing and scoring run locally in the browser.

Does :where() add specificity?

No. This calculator treats :where() as zero specificity, matching modern CSS behavior.