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

4m read timeFrom css-tricks.com
Post cover image
Table of contents
html:root:scope or &‌:has(head) or :has(body):not(* *)

Sort: