CSS :root Pseudo-Class

Definition and Usage

CSS :root Pseudo-classes are used to match the root element of the document.

In HTML, the root element is always <html> Element.

Example

Set the background color and padding for the root element of the document:

:root {
  background-color: red;
  padding: 30px;
{}

Try It Yourself

CSS Syntax

:root {
  css declarations;
{}

Technical Details

Version: CSS3

Browser Support

The numbers in the table specify the first browser version to fully support this pseudo-class.

Chrome Edge Firefox Safari Opera
1 12 1 1 9.6