HTML: the Root Element
What is Root Element
- Root element of HTML is the element represented by the
html
tag. - Root element of XML may be other, depending on the XML. e.g. root element of SVG is represented by the
svg
tag. 〔see Practical SVG Tutorial〕 - Root element of Atom Webfeed is
feed
.
Why is Root Element Important
It's important because many CSS's meaning refers to it.
For example:
- length unit
rem
refers to root element. position
property refers to root element.
CSS Syntax for Root Element
In CSS, the root can be specified by:
:root
For example, make all text red:
:root { color: red; }
This is often used when using CSS variables.