:root CSS Pseudo Class

Description

The :root pseudo-class defines the root element of a document. In HTML, this selector always matches the <html> element, but in styles, priority is :root higher than the html selector.

Syntax

:root { ... } 

Example

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
:root {
background: #988871;
padding-top: 30px;
}
html {
background: red;
padding-top: 0;
}

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
912119.51
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
37184X1X