initial 6r723
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. 6o681z
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 3y6d6i
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 176n59
View this demo on the Codrops PlaygroundBrowser s162l
CSS initial value 4v2f6g
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 1i5h4c
- 4
- 19
- No
- 15
- 3.2
Mobile / Tablet 1u2r2g
- 4.0
- 2.3
- No
- 66
- 60
Notes 5i3os
The initial
keyword is ed without prefixes starting Firefox v24.