TIL, 2022-06-15, Initial/Inherit in CSS?
- Reference
JSON.stringify
would be the fastest way to get the results of some JSON in a copy-paste compatible way.
Understanding the “Initial”, “Inherit” and “Unset” CSS Keywords
- Every property has an initial value. Like
line-height
will havenormal
. - Each User-Agent has a browser style. This is why font-size might be different in other browsers for H1. By itself, HTML elements do not have initial style values.
inherit
- tells the browser to search for the closest parent element’s value and let the current element inherit that value.initial
- Use the default value of the given property.- For a
div
,display: initial
actually means it becomes aninline
rather than ablock
- this is causeblock
is from the user agent.
- For a
unset
:- Inherited properties - example of this is
color
:color
cascades down. Anunset
on the child would setinherit
- same.unset
- same.
- Non-inherited properties -
border
does not cascade down.inherit
- set to whatever is the closest.unset
- remove style.
- Inherited properties - example of this is
- So it really doesn’t remove a cascaded rule :(