:root CSS Pseudo Class
Description
The :root
pseudo-class defines the root element of a document. In HTML, this selector always matches the <html> element, but in styles, priority is :root
higher than the html selector.
Syntax
:root { ... }
Example
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
:root {
background: #988871;
padding-top: 30px;
}
html {
background: red;
padding-top: 0;
}
Browser Support
Desktop | |||||
9 | 12 | 1 | 1 | 9.5 | 1 |
Tablets / Mobile | |||||
![]() |
|||||
37 | 18 | 4 | X | 1 | X |
Last updated by CSSPortal on: 25th November 2019
CSS Pseudo Elements
CSS Pseudo Classes
- :active
- :checked
- :default
- :disabled
- :empty
- :enabled
- :first-child
- :first-of-type
- :focus
- :fullscreen
- :hover
- :in-range
- :indeterminate
- :invalid
- :lang
- :last-child
- :last-of-type
- :link
- :not
- :nth-child
- :nth-last-child
- :nth-last-of-type
- :nth-of-type
- :only-child
- :only-of-type
- :optional
- :out-of-range
- :read-only
- :read-write
- :required
- :root
- :target
- :valid
- :visited