Skip to main content
AllDevToolsHub
🎯

CSS Specificity Calculator

100% Local

Calculate and compare CSS selector specificity with visual breakdown.

CSS Specificity Calculator

IDs (A)

1

Classes (B)

2

Elements (C)

1

Score

121

Specificity notation

(1,2,1)

1
ID
2
CLS
1
EL
Try:
This tool runs entirely in your browser. Your input is never uploaded, logged, or sent to AllDevToolsHub or anyone else, and it keeps working offline once the page has loaded.

Paste a CSS selector to see its specificity score broken down by ID, class, and element weight.

Overview

What is CSS Specificity Calculator?

Calculate CSS selector specificity broken into IDs (A), classes (B), and elements (C). Compare multiple selectors ranked, with :is(), :not(), :where() guide.
FAQ

Frequently Asked Questions

Reference

Technical Deep Dive

DESIGN TOOLS

CSS Specificity Calculator

Instantly calculate the specificity of any CSS selector, broken into IDs (A), classes/attributes/pseudo-classes (B), and elements/pseudo-elements (C). Compare multiple selectors ranked by specificity, load example selectors, and read the built-in specificity reference guide covering :is(), :not(), :where(), and !important.

🎨

Pixel-Precise Output

Generates CSS, tokens, or assets that match what your design system expects.

👀

Live Visual Preview

See changes the moment you make them, no copy-paste cycle between tool and IDE.

📋

Copy-Paste Ready

Output is formatted for direct use in stylesheets, Tailwind configs, or Figma tokens.

01 Specificity Weight Matrix

Tier Target Selectors Weight Tuple Hierarchy
IDs#header, #nav(1, 0, 0)Highest
Classes.btn, [type], :hover(0, 1, 0)Medium
Elementsdiv, p, ::before(0, 0, 1)Lowest
Global*, :where(), >(0, 0, 0)No Weight

02 Cascade Calculation Pipeline

1
Selector Tokenization The raw selector string is parsed into individual tokens while identifying complex pseudo-classes and combinators.
2
Tiered Accumulation Tokens are categorized into the (A, B, C) bins. Logic for :is() and :not() is applied by taking the max specificity of arguments.
3
Precedence Ranking Final tuples are compared left-to-right (ID > Class > Element) to determine the winning declaration in the CSS cascade.

You Might Also Need