Skip to content
Related Articles
Open in App
Not now

Related Articles

CSS | :root Selector

Improve Article
Save Article
Like Article
  • Last Updated : 23 Aug, 2022
Improve Article
Save Article
Like Article

The :root selector is used to select all the elements of an HTML Documents. This selector covers all the HTML elements or tags. 

Syntax:

:root {
    // CSS property
} 

Example: 

html




<!DOCTYPE html>
<html>
    <head>
        <title>root selector</title>
        <style>
            h1 {
                color:White;
            }
            :root {
                background: green;
            }
            body {
                text-align:center;
            }
        </style>
    </head>
    <body>
        <h1>GeeksforGeeks</h1>
        <h2>:root selector</h2>
        <p>The root of document is &lt;body&gt; tag</p>
    </body>
</html>                   

Output:

  

Supported Browsers: The browser supported by :root selector are listed below:

  • Apple Safari 1.0 and above
  • Google Chrome 1.0 and above
  • Edge 12.0 and above
  • Firefox 1.0 and above
  • Opera 9.5 and above
My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!