initial 4k3z13
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. 563u38
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 3e5p5z
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; }
Live Demo 2x4j2k
View this demo on the Codrops PlaygroundBrowser k5t66
CSS initial value 4a6h5f
A CSS value that will apply a property's initial value as defined in the CSS specification that defines the property
W3C Candidate Recommendation
ed from the following versions:
Desktop 3n671n
- 4
- 19
- No
- 15
- 3.2
Mobile / Tablet 4q224p
- 4.0
- 2.3
- No
- 66
- 60
Notes z5jo
The initial
keyword is ed without prefixes starting Firefox v24.