A fun exploration of the various ways to select the HTML root element in CSS beyond the obvious `html` selector. Covers `:root`, `:scope`, the `&` nesting selector, `:has(head)` / `:has(body)`, and the quirky `:not(* *)` pattern. Each approach is explained with its specificity implications, practical use cases, and notable edge cases — including when `:scope` differs from `:root` inside `@scope` blocks and how `&` behaves outside of nested contexts.

1 Comment
Sort: