Open In App
Related Articles

CSS :root Selector

Improve Article
Improve
Save Article
Save
Like Article
Like

The :root selector is used to select all the elements of an HTML Document. 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 body 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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 04 Aug, 2023
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials