initial
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since November 2015.
The initial CSS keyword applies the initial (or default) value of a property to an element. It can be applied to any CSS property, including the CSS shorthand property all. With all set to initial, all CSS properties can be restored to their respective initial values in one go instead of restoring each one separately.
On inherited properties, the initial value may be unexpected. You should consider using the inherit, unset, revert, or revert-layer keywords instead.
Examples
>Basic usage
In this example, we use the initial keyword to reset an element's color and font-size property values.
HTML
<p>
This text is red and large.
<em
>This text is in the initial color (typically black) and initial size
(typically 16px).</em
>
This is red and large again.
</p>
CSS
We set color and font-size on the <p> element, then set those properties to initial on the <em> element to reset them.
p {
color: red;
font-size: 2rem;
}
em {
color: initial;
font-size: initial;
}
Result
With the initial keyword in this example, the color and font-size values on the em element are restored to the initial values for color and font-size, respectively.
Specifications
| Specification |
|---|
| CSS Cascading and Inheritance Level 4> # initial> |
Browser compatibility
See also
inherit,revert,revert-layer, andunsetkeywordsall- Inheritance