Computer >> Computer tutorials >  >> Programming >> CSS

Role of CSS :root Selector


Use the CSS : root selector to style document’s root element.

Example

You can try to run the following code to implement the :root Selector

<!DOCTYPE html>
<html>
   <head>
      <style>
         :root {
            background: blue;
            color: white;
         }
      </style>
   </head>
   <body>
      <h1>Heading</h1>
      <p>This is demo text.</p>
   </body>
</html>