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.

范例

Using initial to reset color for an element

HTML

<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>
					

CSS

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.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
initial Chrome 完整支持 1 Edge 完整支持 13 Firefox 完整支持 19
完整支持 19
不支持 1 — 24 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 不支持 No Opera 完整支持 15 Safari 完整支持 1.2 WebView Android 完整支持 1 Chrome Android 完整支持 18 Firefox Android 完整支持 19
完整支持 19
不支持 4 — 24 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
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.

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考