mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 15:18:01 +00:00
Add :root Has Higher Specificity Than html as a css til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||||
|
|
||||||
_757 TILs and counting..._
|
_758 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -98,6 +98,7 @@ _757 TILs and counting..._
|
|||||||
- [Lighten And Darken With SCSS](css/lighten-and-darken-with-scss.md)
|
- [Lighten And Darken With SCSS](css/lighten-and-darken-with-scss.md)
|
||||||
- [Make A Block Of Text Respect New Lines](css/make-a-block-of-text-respect-new-lines.md)
|
- [Make A Block Of Text Respect New Lines](css/make-a-block-of-text-respect-new-lines.md)
|
||||||
- [Parameterized SCSS Mixins](css/parameterized-scss-mixins.md)
|
- [Parameterized SCSS Mixins](css/parameterized-scss-mixins.md)
|
||||||
|
- [:root Has Higher Specificity Than html](css/root-has-higher-specificity-than-html.md)
|
||||||
- [Style A Background With A Linear Gradient](css/style-a-background-with-a-linear-gradient.md)
|
- [Style A Background With A Linear Gradient](css/style-a-background-with-a-linear-gradient.md)
|
||||||
|
|
||||||
### Devops
|
### Devops
|
||||||
|
|||||||
20
css/root-has-higher-specificity-than-html.md
Normal file
20
css/root-has-higher-specificity-than-html.md
Normal 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)
|
||||||
Reference in New Issue
Block a user