initial CSS关键字将属性的初始(或默认)值应用于元素。不应将初始值与浏览器样式表指定的值混淆。它可以应用于任何CSS属性。这包括CSS简写allinitial 可用于将所有CSS属性恢复到其初始状态。

注意:在继承的属性上,初始值可能是意外的。你应该考虑使用 inherit, unset,或revert 关键字代替。

示例

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

Specifications

Specification Status Comment
CSS Cascading and Inheritance Level 4
initial
Candidate Recommendation No changes from Level 3.
CSS Cascading and Inheritance Level 3
initial
Candidate Recommendation Initial definition.

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 1Edge Full support YesFirefox Full support 19
Full support 19
No support 1 — 24
Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE No support NoOpera Full support 15Safari Full support 1.2WebView Android Full support 1Chrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 19
Full support 19
No support 4 — 24
Prefixed
Prefixed Implemented with the vendor prefix: -moz-
Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

 

参见

  • Use unset to set a property to its inherited value if it inherits, or to its initial value if not.
  • Use revert to reset a property to the value established by the user-agent stylesheet (or by user styles, if any exist).
  • Use inherit to make an element's property the same as its parent.
  • The all property lets you reset all properties to their initial, inherited, reverted, or unset state at once.

文档标签和贡献者

此页面的贡献者: zhangchen, beyondbycyx
最后编辑者: zhangchen,