DevKits

CSS Specificity Calculator — Calculate CSS Selector Weight Online | DevKits

Calculate CSS selector specificity. See exactly how each part of a selector contributes to the (a,b,c,d) weight. Includes IDs, classes, attributes, pseudo-classes, type selectors, and pseudo-elements. 100% local.

Last updated:

Comments

Type a CSS selector to see its (a,b,c,d) specificity and a per-part explanation.

What is CSS Specificity?

CSS specificity determines which rule wins when multiple selectors target the same element. The spec defines a four-component formula — (a,b,c,d) — where a counts inline styles, b counts IDs, c counts classes/attributes/pseudo-classes, and d counts type/pseudo-element selectors. The values are compared left-to-right: (0,1,0,0) beats (0,0,99,0). The !important flag and universal selector (*) are special cases: !important is a separate overriding bit, and * contributes 0 to all components.

How to calculate specificity

  1. 1Type or paste a CSS selector.
  2. 2The specificity (a,b,c,d) appears instantly.
  3. 3Review the per-part breakdown to understand which component of the selector contributes what.

Frequently Asked Questions

What do the 4 numbers (a,b,c,d) mean?

a = inline styles (1 or 0), b = ID selectors, c = classes / attributes / pseudo-classes, d = type selectors / pseudo-elements. The higher the number read left to right, the higher the specificity. Example: 0,1,2,1 beats 0,0,3,0 because 1 > 0 in the b column.

The !important rule — how does that work?

!important breaks specificity entirely. A rule with !important overrides any non-!important rule, regardless of specificity. The !important flag acts as a one-bit column to the left of a — a single !important declaration beats a thousand ID selectors.

Try Next

Meta Tag Preview

Preview how your page will appear in Google search results and social share cards on Facebook, Twitter/X, and LinkedIn. Parses <title>, meta description, canonical, and full Open Graph / Twitter Card tags with diagnostics. 100% local.

Related Tools

Reference & Guides