CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS root Selector (:root)


What is :root Selector?

CSS root selector select root element of the document.

Browser Compatibility

  • Google Chrome 2+
  • Mozilla Firefox 1.5+
  • Internet Explorer 9+
  • Opera 9.5+
  • Safari 3.1+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.

Syntax

General syntax of :root selector,

:root {
	property: value;
	property: value;
	...
}

Example:

CSS :root selector select root element of the document.

<style type="text/css">
    :root {
        background:#ff0000;
    }
    div {
        width:400px;
        height:130px;
        border: 1px solid yellow;
    }
</style>
</head>
<body>
    <div>
        <h1>This is a heading</h1>
    </div>
</body>

Run it...   »

Example Result: