字體加粗
font-weight 屬性設置文本的粗細。
使用 bold 關鍵字可以將文本設置為粗體。 ( 推薦學習:CSS基礎教程 )
關鍵字 100 ~ 900 為字體指定了 9 級加粗度。如果一個字體內置了這些加粗級別,那么這些數(shù)字就直接映射到預定義的級別,100 對應最細的字體變形,900 對應最粗的字體變形。數(shù)字 400 等價于 normal,而 700 等價于 bold。
如果將元素的加粗設置為 bolder,瀏覽器會設置比所繼承值更粗的一個字體加粗。與此相反,關鍵詞 lighter 會導致瀏覽器將加粗度下移而不是上移。
實例
<html> <head> <style type="text/css"> p.normal {font-weight: normal} p.thick {font-weight: bold} p.thicker {font-weight: 900} </style> </head> <body> <p class="normal">This is a paragraph</p> <p class="thick">This is a paragraph</p> <p class="thicker">This is a paragraph</p> </body> </html>