English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rule (RULES)

Complete List of CSS Properties

CSS3 :root Selector

:root This CSS pseudo-class matches the root element of the document tree. For HTML, :root represents the <html> element, except for higher priority, it is the same as the html selector.

Complete CSS Selector Reference Manual

Online Example

Set the background color of the HTML document:

!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
<style> 
:root
{
 background:green;
 color:#fff;
}
</style>
</head>
<body>
<p>First paragraph.</p>
<p>Second paragraph.</p>
<p>Third paragraph.</p>
</body>
</html>
Test to see ‹/›

Definition and Usage

:root

The :root selector matches the root element of the document.

The root element in HTML is always an HTML element.

Browser Compatibility

The numbers in the table indicate the first browser version that supports the attribute.

Selector




:root4.09.03.53.29.6

Complete CSS Selector Reference Manual