:root
CSS sözde-sınıfı dökümanda bulunan kök elemanı yerine geçer (yani onu temel alır). Örneğin HTML'de :root
dökümanı oluşturan <html>
öğesini temsil eder ve html
seçicisi ile aynıdır, ancak önceliği daha yüksektir.
/* Dökümandaki kök elemanı seçer:
Bu HTML'de <html> oluyor. */
:root {
background: royalblue;
}
Sözdizimi
:root
Örnek
:root
global CSS değişkenleri tanımlarken kullanışlı olabilir:
:root {
--ana-renk: green;
--paragraf-boslugu: 5px 0;
}
Tanımlamalar
Tanımlama | Durum | Açıklama |
---|---|---|
Selectors Level 4 The definition of ':root' in that specification. |
Working Draft | Değişiklik yok. |
Selectors Level 3 The definition of ':root' in that specification. |
Recommendation | Başlangıç tanımı. |
Tarayıcı Uyumluluğu
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.