指定值
CSS 属性的**指定值**是它从文档样式表中接收到的值。给定属性的指定值根据以下规则确定
- 如果文档的样式表显式指定了属性的值,则将使用该值。
- 如果文档的样式表未指定值,但它是继承属性,则该值将取自父元素。
- 如果以上都不适用,则将使用元素的初始值。
示例
HTML
html
<p>My specified color is given explicitly in the CSS.</p>
<div>
The specified values of all my properties default to their initial values,
because none of them are given in the CSS.
</div>
<div class="fun">
<p>
The specified value of my font family is not given explicitly in the CSS, so
it is inherited from my parent. However, the border is not an inheriting
property.
</p>
</div>
CSS
css
.fun {
border: 1px dotted pink;
font-family: fantasy;
}
p {
color: green;
}
结果
规范
规范 |
---|
层叠样式表级别 2 修订版 2 (CSS 2.2) 规范 # 指定值 |