CSS | :root Selector
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:
<!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> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by :root selector are listed below:
- Apple Safari 3.2
- Google Chrome 4.0
- Firefox 3.5
- Opera 9.6
- Internet Explorer 9.0
Recommended Posts:
- jQuery | :root Selector
- CSS | * Selector
- CSS | :not Selector
- CSS | ::before selector
- CSS | #id Selector
- CSS | ::after Selector
- CSS | :enabled Selector
- CSS | :focus Selector
- CSS | :lang Selector
- CSS | :only-of-type Selector
- CSS | :link Selector
- jQuery | * Selector
- jQuery | :odd Selector
- CSS | :default Selector
- CSS | Attribute Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



