Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Custom Properties, Cascade and Global Keywords

The initial keyword

Reference for the CSS initial keyword: it resets a property to its specification default, ignoring the browser style sheet. Examples and pitfalls.

The initial keyword sets a property to its initial value, the default defined in the CSS specification for that property. It works on every CSS property and ignores both inheritance and the browser's default style sheet.

That last point trips people up. The specification says display starts as inline, so div { display: initial } makes a <div> inline, even though browsers normally style <div> as block. If you want the browser's own default instead, use revert.

CSS
.reset { color: initial; margin: initial; }

Try it

initial vs the browser default

Syntax

CSS
property: initial;
  • Works on: every property, including shorthands (all their longhands reset)
  • Result: the property's initial value from its specification, which is listed on every property page in this reference
  • Custom properties: --x: initial sets the property to the guaranteed-invalid value, as if it was never set

Values

Syntax Description
property: initial Uses the specified default. For color that is the UA-dependent "canvas text" color, usually black; for margin it is 0; for display it is inline.
all: initial Resets every property of the element; see all.

Usage notes

  • Not the same as the browser default. Browser style sheets give h1 a big bold font and ul a left margin. initial removes those too, because it goes to the specification value, not the user-agent style sheet value.
  • Beats inheritance. initial on color stops the value inherited from the parent, which unset would not (unset inherits for inherited properties).
  • Good fits: clearing an earlier declaration in a state rule (margin-left: initial), or breaking the link to an inherited custom property.
  • Prefer unset or revert when you just want to "forget my styling". They are less surprising.

Browser support

Supported in all browsers.