font-weight
font-weight 属性规定文本的粗细。
语法
p {font-weight:normal;} p {font-weight:bold;} p {font-weight:900;}
值
值 | 描述 |
---|---|
normal | 默认值。定义标准的字符。 |
bold | 定义粗体字符。 |
bolder | 定义更粗的字符。 |
lighter | 定义更细的字符。 |
100-900 | 定义由粗到细的字符。400 等同于 normal,而 700 等同于 bold。 |
inherit | 规定应该从父元素继承字体的粗细。 |
例子
HTML
<p class="normal">This is a paragraph.</p> <p class="light">This is a paragraph.</p> <p class="thick">This is a paragraph.</p> <p class="thicker">This is a paragraph.</p>
CSS
p.normal {font-weight:normal;} p.light {font-weight:lighter;} p.thick {font-weight:bold;} p.thicker {font-weight:900;}
执行结果
This is a paragraph.
This is a paragraph.
This is a paragraph.
This is a paragraph.