initial
CSS keyword applies the
initial (or default) value
of a property to an element. It can be applied to any CSS property.
This includes the CSS shorthand
all
, with which
initial
can be used to restore all CSS properties to their initial state.
On
inherited properties
, the initial value may be unexpected. You should consider using the
inherit
,
unset
,或
revert
keywords instead.
<p> <span>This text is red.</span> <em>This text is in the initial color (typically black).</em> <span>This is red again.</span> </p>
p {
color: red;
}
em {
color: initial;
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Cascading and Inheritance Level 4
The definition of 'initial' in that specification. |
候选推荐 | No changes from Level 3. |
|
CSS Cascading and Inheritance Level 3
The definition of 'initial' in that specification. |
候选推荐 | 初始定义。 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
initial
|
Chrome 完整支持 1 | Edge 完整支持 13 |
Firefox
完整支持
19
|
IE 不支持 No | Opera 完整支持 15 | Safari 完整支持 1.2 | WebView Android 完整支持 1 | Chrome Android 完整支持 18 |
Firefox Android
完整支持
19
|
Opera Android 完整支持 14 | Safari iOS 完整支持 1 | Samsung Internet Android 完整支持 1.0 |
完整支持
不支持
要求使用供应商前缀或不同名称。
unset
to set a property to its inherited value if it inherits, or to its initial value if not.
revert
to reset a property to the value established by the user-agent stylesheet (or by user styles, if any exist).
inherit
to make an element's property the same as its parent.
all
property lets you reset all properties to their initial, inherited, reverted, or unset state at once.