CSS: :root selector

By Xah Lee. Date: . Last updated: .

Match Root Element (Element with No Parent)

:root

Match the the Root Element .

/* make all text red */
:root { color: red; }

This is often used in CSS Variable, by declaring variables in root, e.g. :root { --mycolor: pink; } .

CSS, Selectors

simple selectors
selector list
relationship selectors (combinators)
special selector
misc

The Root Element