CSS Specificity Calculator

Live

CSS Specificity Calculator works out the specificity of CSS selectors and shows which one wins.

Runs in your browser: what you enter is processed on your device and not uploaded to MyToolDock.

What is CSS Specificity Calculator?

CSS Specificity Calculator works out the specificity of CSS selectors and shows which one wins. It follows the CSS Selectors Level 4 rules: :is(), :not() and :has() take their most specific argument, :where() counts as zero, and pseudo-elements count as elements. Nesting with & is not supported.

How It Works

  1. Enter one or more CSS selectors, one per line, or a list separated by commas in the input fields on this page.
  2. Press the button to run CSS Specificity Calculator.
  3. Read a table with the IDs, classes and elements counted for each selector, its specificity and its rank in the result area, and copy or download it.

Common Uses

Good to Know

If two selectors tie, the one written later in the stylesheet wins. Inline styles and !important are not counted here.

In more detail

Type or paste CSS selectors, one per line. A line with commas gives one row for each selector.

Read the three counts and the rank. Rank 1 is the strongest selector; ties share a rank.

Worked example

Results were compared with the cssselect package on 169 random selectors using IDs, classes, attributes, pseudo-classes, pseudo-elements, combinators and :not(), :is(), :where() and :has(). Cases that package cannot read, such as :nth-child(2 of .x), escaped names and namespaces, were checked against the CSS Selectors Level 4 rules.

Limits

Inline styles, !important, cascade layers and source order are not part of selector specificity, so they are not shown. The nesting symbol & is not supported.

Frequently Asked Questions

How is specificity counted?

IDs first, then classes, attributes and pseudo-classes, then elements and pseudo-elements. A higher count in an earlier place always wins.

What does :where() do?

It adds nothing, which makes it handy for low-priority defaults.

Are my selectors uploaded?

No. They are processed in your browser.

What does CSS Specificity Calculator do?

CSS Specificity Calculator works out the specificity of CSS selectors and shows which one wins. It follows the CSS Selectors Level 4 rules: :is(), :not() and :has() take their most specific argument, :where() counts as zero, and pseudo-elements count as elements. Nesting with & is not supported.

What do I need to enter in CSS Specificity Calculator?

One or more CSS selectors, one per line, or a list separated by commas.

Is my data private in CSS Specificity Calculator?

Your selectors stay in your browser and are not uploaded.

Is MyToolDock CSS Specificity Calculator free to use?

Yes, MyToolDock CSS Specificity Calculator is 100% free with no registration, subscriptions, or limits. All features are fully unlocked.

Where can I learn more about CSS Specificity Calculator and related workflows?

MyToolDock publishes written guides on the topic: Why Front-End Engineers Need a CSS Minifier. Each guide links back to the tools it covers.

Related Tools

CSS Border Radius Generator CSS Box Shadow Generator CSS Flexbox Builder CSS Formatter CSS Minifier CSV to SQL Insert Generator

Guides

More in Developer Tools · Browse all tools

Developer Scratchpad

Copied to clipboard!