Firefox Tomorrow

css keyword

`initial` CSS keyword

View on MDN ↗

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, revert-layer, or revert-rule 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

Interactive exampleOpen the canonical MDN source to run this embedded demo.

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

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also