Example
Set the background color for the HTML document
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
:root
{
background:#ff0000;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
</body>
</html>
Definition and Usage
The :root selector matches the document’s root element.
In HTML, the root element is always the html element.
Browser Support
The :root selector is supported in all major browsers, except IE8 and earlier.
Was this information helpful?

