CSS/Selectors/pseudo-classes/:root

From Web Education Community Group
< CSS‎ | Selectors
Jump to: navigation, search

Pseudo-classes :root

The :root pseudo-class represents an element that is the root of the document. In HTML, this is always the HTML element.

Syntax

selector:root{ properties }


Example

[style.css]

 :root{
   background-color: #ccc;
 }


[index.html]

<body>
<p>This is a paragraph.</p>
</body>

Css3 selectors root.png

CSS defines the :root pseudo-class in 6.6.5.1. :root pseudo-class.