font-weight CSS屬性設(shè)置字體的粗細(xì)。
下表為此屬性的用法說明和版本歷史記錄,以及該屬性在javascript腳本中的使用語法。
默認(rèn)值: | 正常 |
---|---|
適用于: | 所有元素 |
繼承: | 是 |
可動畫制作: | 是。請參考 動畫屬性。 |
版本: | CSS 1,2,3 |
JavaScript語法: | object.style.fontWeight="700" |
該屬性的語法如下:
font-weight: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | initial | inherit
下面的示例演示了如何使用font-weight屬性。
h1 { font-weight: normal; } p { font-weight: bold; }測試看看?/?
下表描述了此屬性的值。
值 | 描述 |
---|---|
normal | 指定普通字符。 |
bold | 指定粗體字符。 |
bolder | 定義更粗的字符。 |
lighter | 選定義更細(xì)字符。 |
100 | 數(shù)值100到900形成一個(gè)有序的序列,其中每個(gè)數(shù)字表示的權(quán)值等于或大于前一個(gè)值。關(guān)鍵字normal等于400,粗體等于700。 |
200 | |
300 | |
400 | |
500 | |
600 | |
700 | |
800 | |
900 | |
initial | 將此屬性設(shè)置為其默認(rèn)值。 |
inherit | 如果指定,則關(guān)聯(lián)元素采用其父元素font-weight的屬性值。 |
font-weight屬性瀏覽器的兼容性,下表中的數(shù)字表示支持該屬性的瀏覽器最低版本號;所有主流瀏覽器均支持該屬性。
![]() |
|
相關(guān)屬性和規(guī)則:font,font-style,font-variant,font-size,line-height,font-family,@font-face。