The :Root Pseudo-Class

The :root selector matches the document's root element. In HTML, the root element is always the html element. In this example, the background color for the HTML document is set:

HTML file: Displayed by browser:
<style>
:root {
    background: #ff0000;
}
</style>
<body>
<h1>The whole webpage will have the background color specified.</h1>
</body>

The whole webpage will have the background color specified.


Back button Table of Contents Next button