Skip to content

Commit ee36333

Browse files
committed
Add :root Has Higher Specificity Than html as a css til
1 parent 4a176b6 commit ee36333

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
1010
For a steady stream of TILs from a variety of rocketeers, checkout
1111
[til.hashrocket.com](https://til.hashrocket.com/).
1212

13-
_757 TILs and counting..._
13+
_758 TILs and counting..._
1414

1515
---
1616

@@ -98,6 +98,7 @@ _757 TILs and counting..._
9898
- [Lighten And Darken With SCSS](css/lighten-and-darken-with-scss.md)
9999
- [Make A Block Of Text Respect New Lines](css/make-a-block-of-text-respect-new-lines.md)
100100
- [Parameterized SCSS Mixins](css/parameterized-scss-mixins.md)
101+
- [:root Has Higher Specificity Than html](css/root-has-higher-specificity-than-html.md)
101102
- [Style A Background With A Linear Gradient](css/style-a-background-with-a-linear-gradient.md)
102103

103104
### Devops
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# :root Has Higher Specificity Than html
2+
3+
The `:root` CSS pseudo-selector and `html` will target the same element --
4+
`<html>`, but `:root` has higher specificity. That means the property rules
5+
declared under `:root` will take precedence over those under `html`.
6+
7+
```css
8+
:root {
9+
background: red;
10+
}
11+
12+
html {
13+
background: blue;
14+
}
15+
```
16+
17+
In the case of the above code, the `<html>` element's background color will
18+
be `red`.
19+
20+
[source](https://developer.mozilla.org/en-US/docs/Web/CSS/:root)

0 commit comments

Comments
 (0)