CSS Reference Data Type

initial

The initial CSS keyword is used to apply a property’s initial value as its specified value (value specified by the CSS author). This means that no matter what the cascaded or inherited value of the property is, it will be “reset” to its default initial value if it takes this keyword.

All CSS properties have initial values, hence, this keyword can be used with any CSS property.

Some CSS properties inherit their values from the cascading nature of CSS. For example, if you set a text color of an element, then all the descendants of that element will inherit the same text color. In such a case, you may want to reset the color of one of the descendants instead of having it inherit the color from its parent, so the initial keyword could be used to do just that. The same applies for properties that are not inherited, but you still want to reset their values to their initial values.

Examples

Assume that you have a container and that you have set the text color of that container to be of a certain color. The following resets the text color of all .original paragraphs inside that container to their default text color.

p.original {
    color: initial;
}
                

The following example will style all h3 tags and give them an italic font style. We’ll use the initial keyword to reset the font style to its initial value (which is normal) for h3 tags that are found inside the sidebar.

h3 {
    font-style: italic;
}

.sidebar h3 {
    font-style: initial;
}
                

Browser Support

CSS initial value

A CSS value that will apply a property's initial value as defined in the CSS specification that defines the property

W3C Candidate Recommendation

Supported from the following versions:

Desktop

  • 4
  • 19
  • No
  • 15
  • 3.2

Mobile / Tablet

  • 4.0
  • 2.3
  • No
  • 129
  • 130

* denotes prefix required.

  • Supported:
  • Yes
  • No
  • Partially
  • Polyfill

Stats from caniuse.com

Notes

The initial keyword is supported without prefixes starting Firefox v24.

Written by . Last updated January 10, 2017 at 9:17 am by Hui Jing Chen.

Do you have a suggestion, question or want to contribute? Submit an issue.