The `:heading` pseudo-selector allows targeting all heading elements (h1-h6) with a single CSS rule instead of listing them individually. It has class-level specificity (0-1-0) and supports functional notation like `:heading(1, 2)` for grouping levels. Currently available only in Firefox Nightly and Safari Technology Preview, it's particularly useful in design systems for setting consistent typography across components while reducing code repetition. Combined with CSS custom properties, it enables overrideable defaults that cascade naturally throughout a codebase.

4m read timeFrom alwaystwisted.com
Post cover image
Table of contents
The Current ApproachEnter :headingTargeting Specific Heading LevelsSome Possible Use CasesComposing :heading With Other SelectorsBrowser Support and TestingA Cleaner Design SystemWrapping Up

Sort: