There are specific values that can be assigned to each property. Stokely's response underscores the importance of distinguishing between inherited and non-inherited properties.
initial
This value is used to set a property to its initial specified value, like color: initial;
. It's important to note that this initial value may not always correspond to the default style sheet value set by the browser.
inherit
When this value is used, a property inherits the computed value of its parent, as in *{box-sizing: inherit;}
.
unset
This keyword functions similarly to the value inherit
for inherited properties and the value initial
for non-inherited properties.
revert
The value is solely determined by the cascade of user and user agent rules, disregarding conflicting author rules when setting the value. However, these rules remain valid based on their specificity.
all
The shorthand property "all" can adopt any of the aforementioned global values. According to MDN Web Docs, this value will apply to all properties except unicode-bidi
and direction
.
The excerpt:
The revert CSS keyword resets the cascaded value of a property back to what it would have been if no changes had been made by the current style origin to the current element. It essentially reverts the property either to its inherited value from its parent or to the default value set by the user agent stylesheet (or by existing user styles).
is somewhat misleading. For many inherited properties, using the declaration property: revert;
effectively behaves the same as property: inherit;
, meaning the calculated value of the parent element is adopted. Exceptions include form elements like input
, select
, textarea
, and button
, where the user agent interrupts the inheritance chain, specifying explicit values for font-family
and font-size
. In such cases, the value revert
causes these elements to adopt the user agent's values. Non-inherited properties always take the value derived from the cascade of user and user agent rules. An example illustrates this concept.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Testing Global Values and Shorthand Property all</title>
<style>
body, div{border: solid 2px;padding:10px;margin: 10px;}
.all-revert { all:revert;}
div{ font-family: 'Courier New', Courier, monospace; }
</style>
</head>
<body style="font-family:serif;color:royalblue;font-size: 24px;">
<div class="all-revert">Default serif (TNR), no margin, no border.</div>
<div>Courier New, margin of 20 pixels, and border.</div>
<button class="all-revert">Arial</button>
<button style="all:unset; border:revert;">Default serif</button>
</body>
</html>
The rule div, button {all: revert;}
affects the div
and button
elements differently. The div
element has all font-related properties set to inherit
, applying the settings from the body element. Conversely, the button
element inherits default font color, size, and type values chosen by the user agent.
The use of the value unset
on inherited properties mirrors the effect of inherit
; hence, the font properties of the second button inherit from the body element, while the border adopts the user agent's settings. For non-inherited properties like border
, padding
, and margin
, the 'revert' value leads to adoption of user agent values.