多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# CSS font-weight 属性 ## 实例 设置三个段落的字体的粗细: ``` p.normal {font-weight:normal;} p.thick {font-weight:bold;} p.thicker {font-weight:900;} ``` ## 浏览器支持 | IE | Firefox | Chrome | Safari | Opera | | --- | --- | --- | --- | --- | 所有主流浏览器都支持 font-weight 属性。 注释:任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。 ## 定义和用法 font-weight 属性设置文本的粗细。 ### 说明 该属性用于设置显示元素的文本中所用的字体加粗。数字值 400 相当于 关键字 normal,700 等价于 bold。每个数字值对应的字体加粗必须至少与下一个最小数字一样细,而且至少与下一个最大数字一样粗。 | 默认值: | normal | | --- | --- | | 继承性: | yes | | --- | --- | | 版本: | CSS1 | | --- | --- | | JavaScript 语法: | _object_.style.fontWeight="900" | | --- | --- | ## 可能的值 | 值 | 描述 | | --- | --- | | normal | 默认值。定义标准的字符。 | | bold | 定义粗体字符。 | | bolder | 定义更粗的字符。 | | lighter | 定义更细的字符。 | | * 100 * 200 * 300 * 400 * 500 * 600 * 700 * 800 * 900 | 定义由粗到细的字符。400 等同于 normal,而 700 等同于 bold。 | | inherit | 规定应该从父元素继承字体的粗细。 | ## TIY 实例 [设置字体的粗细](/tiy/t.asp?f=csse_font-weight) 本例演示如何设置字体的粗细。 ``` <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> ``` ## 相关页面 CSS 教程:[CSS 字体](/css/css_font.asp "CSS 字体") CSS 参考手册:[CSS font 属性](/cssref/pr_font_font.asp "CSS font 属性") HTML DOM 参考手册:[fontWeight 属性](/jsref/prop_style_fontweight.asp "HTML DOM fontWeight 属性")