CSS provides five special universal property values for controlling inheritance.
Every CSS property accepts these values
inherit
- Sets the property value applied to a selected element to be the same
as that of its parent element
- Effectively, this "turns on inheritance"
- The inherited value of a property on an element is the computed value of the
property on the element's parent element
initial
- Sets the property value to the
initial
value of that property
- The
initial value
of a CSS property is its default
value, as listed in its definition table in the specification
revert
The behavior depends on the cascade origin
to which
the declaration
belongs
user-agent origin
equivalent to unset
user origin
- Rolls back the cascaded value to the
user-agent
level
-
The specified value is calculated as if no
author-origin
or user-origin
rules were specified for this property
on this element
author origin
- Rolls back the cascaded value to the
user
level
- The specified value is calculated as if
no
author-origin
rules were
specified for this property
on this element
- see
W3C
revert-layer
-
Resets the property value applied to a selected element
to the value established in a previous cascade layer.
unset
Resets the property to its natural
value, which means that
- If the property is naturally inherited it acts like
inherit
- Otherwise, it acts like
initial
tomgdow
<a href="https://tomgdoww.com" id="mydefault">tomgdow</a>
The default link color
(NOT
background-color
) is blue
,
which comes from the browser
//CSS
.divcontent {color: lime;}
#myinherit {color: inherit;}
// HTML
<div class="divcontent">
<a href="https://tomgdoww.com" id="myinherit">tomgdow</a>
</div>
The link color
(NOT
background-color
) is inherited from the parent class
//CSS
.divcontent {color: lime;}
#myinitial{color: initial;}
// HTML
<div class="divcontent">
<a href="https://tomgdoww.com" id="myinitial">tomgdow</a>
</div>
-
The link
color
(NOT
background-color
) is initial value
of the CSS color
property
-
In the case of
color
, the initial value is canvasText
-
canvasText
is a system color keyword, and maps to the existing
WindowText
system color keyword
Author Origin
//CSS
.divcontent {color: lime;}
#myrevert {color: revert;}
// HTML
<div class="divcontent">
<a href="https://tomgdoww.com" id="myrevert">tomgdow</a>
</div>
As color
is calculated as if no
author-origin
rules were specified, the link color
appears
blue
User Origin
//CSS (USER stylesheet)
#myrevert {color: red;}
Inclusion of the above CSS rule in the user stylesheet
, but
othewise with identical code to author origin
above,
results in a red link color
//CSS
@layer flayer, llayer;
@layer llayer {
.myrevertLayer {color: revert-layer;}
}
@layer flayer {
.myrevertLayer {color: magenta;}
}
.myrevertlayer {color: revert-layer;}
// HTML
<div class="divcontent">
<a href = "https://tomgdoww.com"
id = "myrevertLayer"
class = "myrevertLayer">
tomgdow</a>
</div>
The revert-layer
value causes the CSS rule from the previous layer
(flayer
) to be applied
//CSS
.divcontent {color: lime;}
#myunset {color: unset;}
// HTML
<div class="divcontent">
<a href="https://tomgdoww.com" id="myunset">tomgdow</a>
</div>
As color
is naturally inherited, unset
acts like
inherit