初始值 | initial
initial
initial
是将属性的初始值( initial
value)赋给元素 . initial
适用于所有的css 属性(属性的initial
值可在属性表中查到),包括css 简写属性(全局属性)all
.
在继承的属性上,初始值可能会令人惊讶。你应该考虑使用inherit
,unset
或revert
关键字来代替。
示例
HTML
<p>
<span>This text is red.</span>
<em>This text is in the initial color (e.g., black).</em>
<span>This is red again.</span>
</p>
CSS
p {
color: red;
}
em {
color: initial;
}
规范
Specification | Status | Comment |
---|---|---|
CSS Cascading and Inheritance Level 4The definition of 'initial' in that specification. | Working Draft | No changes from Level 3. |
CSS Cascading and Inheritance Level 3The definition of 'initial' in that specification. | Candidate Recommendation | Defines what an initial value is. |
CSS Values and Units Module Level 3The definition of 'initial' in that specification. | Candidate Recommendation | Defines the keyword. |
浏览器兼容性
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 1.0 | 3.5 (1.9.1)-moz1 19.0 (19.0) | No support | 15.0 | 1.2 |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1.9.1)-moz1 19.0 (19.0) | No support | No support | (Yes) |