網(wǎng)站樣式css加粗代碼是“文字元素{font-weight: bold;}”或“文字元素{font-weight: bolder;}”。font-weight屬性用于設置文本的粗細,當該屬性的值設置為“bold”時可定義粗體字符,設置為“bolder”時可定義更粗的字符;font-weight屬性的值也可設置為數(shù)值“700”、“800”或“900”,這樣也可實現(xiàn)文字加粗效果。
本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
網(wǎng)站樣式css加粗代碼:
文字元素{font-weight: bold;} 文字元素{font-weight: bolder;}
用到的CSS屬性為:字體加粗屬性“font-weight”。
font-weight 屬性可設置文本的粗細,支持多種屬性值:
值 | 描述 |
---|---|
normal | 默認值。定義標準的字符,等于400。 |
bold | 定義粗體字符,等于700。 |
bolder | 定義更粗的字符。 |
lighter | 定義更細的字符。 |
|
定義由細到粗的字符。400 等同于 normal,而 700 等同于 bold。 |
示例:四段文字設置不同的字體粗細
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>css 文字加粗</title> <style> p.normal { font-weight: normal; } p.bold { font-weight: bold; } p.bolder { font-weight: bolder; } p.thicker { font-weight: 900; } </style> </head> <body> <p class="normal">測試文本!</p> <p class="bold">測試文本!</p> <p class="bolder">測試文本!</p> <p class="thicker">測試文本!</p> </body> </html>
說明:strong、b、h1~h6等標簽的font-weight默認就是bold
(學習視頻分享:css視頻教程)