initial 66a3i
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. 3y1g2d
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 2h2053
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 6b4m17
View this demo on the Codrops PlaygroundBrowser 572e63
CSS initial value 3x42w
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 ea5q
- 4
- 19
- No
- 15
- 3.2
Mobile / Tablet 6s2f12
- 4.0
- 2.3
- No
- 66
- 60
Notes 441w3q
The initial
keyword is ed without prefixes starting Firefox v24.