CSS3 :root Selector

Example

Set the background color for the HTML document:

:root
{
background:#ff0000;
}

Try it yourself »

Definition and Usage

The :root selector matches the document’s root element.

In HTML, the root element is always the html element.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The :root selector is supported in all major browsers, except Internet Explorer.