AES Encryption Explained: How It Works and Why It Matters
Jun 23, 2026
Calculate, compare, and understand CSS selector specificity.
CSS specificity determines which styles are applied when multiple rules target the same element. It is calculated as a four-part weight:
| Category | Examples | Weight |
|---|---|---|
| Inline styles | class="page_speed_7" | 1, 0, 0, 0 |
| ID selectors | #header, #main-content | 0, 1, 0, 0 |
| Class, attribute & pseudo-class | .container, [type="text"], :hover | 0, 0, 1, 0 |
| Elements & pseudo-elements | div, h1, ::before, :first-line | 0, 0, 0, 1 |
The !important declaration overrides all specificity calculations and should be used sparingly.
Understanding specificity helps you debug CSS conflicts and write more maintainable stylesheets. When two selectors target the same element, the one with higher specificity wins.
The score combines all four categories: (inline x 1000) + (ID x 100) + (class/attribute x 10) + (element x 1). This gives you a quick numerical comparison.
Yes. The :not() pseudo-class itself does not add specificity, but the selector inside the parentheses does. For example, :not(#id) contributes an ID-level specificity.
Blog
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026