css 中给字体加粗可以通过 font-weight 属性,默认值 normal,加粗值 bold,还支持更轻(lighter)、更重(bolder)、100-900 数值(400 为正常)。

在 CSS 中给字体加粗
在 CSS 中给字体加粗非常简单,可以使用 font-weight 属性。
HTML 代码
<code class="html"><p>这是普通文本</p> <p><strong>这是加粗文本</strong></p></code>
CSS 代码
<code class="<a href=" https: target="_blank">css">p {
font-weight: normal;
}
strong {
font-weight: bold;
}</code>
在这个示例中,normal 是字体的默认权重,而 bold 是加粗权重。
除了 normal 和 bold 之外,font-weight 属性还支持以下值:
- lighter:比当前字体权重更轻
- bolder:比当前字体权重更重
- 100:最轻的字体权重
- 200 – 900:介于轻和重的字体权重之间(其中 400 是正常权重)
示例
要将文本加粗为中等粗细,可以使用以下 CSS:
<code class="css">p {
font-weight: 600;
}</code>
浏览器支持
font-weight 属性得到所有现代浏览器的良好支持。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END




















































暂无评论内容