指定值
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) 規範 # 指定值 |