Open source · Web tool
CSS Specificity Wars
Compare CSS selectors and understand which wins
Suprabhat KumarUpdated:
Project proof
My role
- Author and maintainer
Constraints
- Built with Astro 7, strict TypeScript, and plain modern CSS using @layer, without a UI framework. The engine is pure TypeScript with no DOM dependency.
Key decisions
- Fix suggestions: :where(), @layer, then !important as a last resort
The lab
CSS Specificity Wars compares selectors, explains specificity and the cascade, expands nesting, and suggests fixes with shareable results.
Selectors and the cascade
Built with Astro 7, strict TypeScript, and plain modern CSS using @layer, without a UI framework. The engine is pure TypeScript with no DOM dependency.
- Selector scores with per-part breakdowns; nesting expansion shows what & becomes
- Seven cascade steps: origin and importance, shadow context, inline style, @layer, specificity, @scope proximity, and order of appearance; the deciding step is marked
- Fix suggestions: :where(), @layer, then !important as a last resort
- Shareable links
Verification and delivery
As of 12 November 2026: selector scoring was checked against 40 reference selectors from Selectors Level 4 and edge cases. Four libraries were tested before one was chosen. There are 197 unit tests, plus end-to-end and axe accessibility tests in Chromium, Firefox, and WebKit.
The MIT-licensed source is public on GitHub. GitHub Pages hosts the site; GitHub Actions deploys it with no stored secrets.
Outcomes
- As of 12 November 2026: the tool page loads 2.3 KB of gzipped JavaScript before interaction. Its default result is rendered at build time and works without JavaScript. PageSpeed Insights scores are 100 on mobile and desktop.
Next steps
- Open tool (English)
- Source on GitHub