字型速記
使用語法:
element {
    font: [font-style] [font-variant] [font-weight] [font-size/line-height] [font-family];
}
你可以使用 font 速記在一個宣告中包含所有與字型相關的樣式。只需使用 font 屬性,並按正確順序輸入值。
例如,要使所有 p 元素以字型大小 20px 加粗並使用 Arial 作為字型系列,通常可以按如下方式對其進行編碼:
p {
    font-weight: bold;
    font-size: 20px;
    font-family: Arial, sans-serif;
}
但是使用字型速記可以如下壓縮:
p {
    font: bold 20px Arial, sans-serif;
}
注意 :因為 font-style,font-variant,font-weight 和 line-height 是可選的,所以在這個例子中跳過它們中的三個。請務必注意,使用快捷方式會重置未給出的其他屬性。另一個重點是字型快捷方式的兩個必要屬性是 font-size 和 font-family。如果它們都不包括在內,則忽略該快捷方式。
每個屬性的初始值:
- font-style: normal;
- font-variant: normal;
- font-weight: normal;
- font-stretch: normal;
- font-size: medium;
- line-height: normal;
- font-family- 取決於使用者代理