pseudo-class

:root — CSS reference

Matches the document root element; in HTML this is html, not body. Its specificity is that of a pseudo-class.

Formal Syntax & Structure

css syntaxcss
:root

Working Example

Example Snippetcss
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Selector lab</title><style>:where(.sample) { color: rgb(32, 32, 32); }:root { color: rgb(0, 96, 80); }</style></head><body><p id="b" class="sample">B</p></body></html>
CSS Reference