This translation is incomplete. Please help translate this article from English.
La pseudo-class CSS :root coincideix amb l'element arrel de l'arbre que representa el document. En HTML, :root representa l'element <html> i és idèntic al selector html, excepte que la seva Especificitat és més alta.
/* Selecciona l'element arrel del document: <html> en el cas de l'HTML */
:root {
background: yellow;
}
Sintaxi
:root
Exemple
El ùs de :root pot ser útil per declarar Variables CSS globals:
:root {
--main-color: hotpink;
--pane-padding: 5px 42px;
}
Especificacions
| Especificació | Estat | Comentari |
|---|---|---|
| Selectors Level 4 The definition of ':root' in that specification. |
Working Draft | Sense canvis. |
| Selectors Level 3 The definition of ':root' in that specification. |
Recommendation | Definició inicial. |
Navegadors compatibles
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
| Descripció | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Suport bàsic | 1 | (Yes) | 1.0 (1.7 or earlier) | 9 | 9.5 | 1.0 |
| Descripció | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Suport bàsic | ? | (Yes) | ? | ? | ? | ? |
Document Tags and Contributors
Tags:
Contributors to this page:
mdnwebdocs-bot,
Legioinvicta
Last updated by:
mdnwebdocs-bot,