1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add :root Has Higher Specificity Than html as a css til

This commit is contained in:
jbranchaud
2019-02-05 09:39:47 -06:00
parent 4a176b68b5
commit ee363335f7
2 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
# :root Has Higher Specificity Than html
The `:root` CSS pseudo-selector and `html` will target the same element --
`<html>`, but `:root` has higher specificity. That means the property rules
declared under `:root` will take precedence over those under `html`.
```css
:root {
background: red;
}
html {
background: blue;
}
```
In the case of the above code, the `<html>` element's background color will
be `red`.
[source](https://developer.mozilla.org/en-US/docs/Web/CSS/:root)