PHP前端开发

css中怎么给字体加粗

百变鹏仔 4周前 (09-19) #CSS
文章标签 字体
css 中给字体加粗可以通过 font-weight 属性,默认值 normal,加粗值 bold,还支持更轻(lighter)、更重(bolder)、100-900 数值(400 为正常)。

在 CSS 中给字体加粗

在 CSS 中给字体加粗非常简单,可以使用 font-weight 属性。

HTML 代码

<p>这是普通文本</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/cb6835dc7db1" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">前端免费学习笔记(深入)</a>”;</p><p><strong>这是加粗文本</strong></p>

CSS 代码

p {  font-weight: normal;}strong {  font-weight: bold;}

在这个示例中,normal 是字体的默认权重,而 bold 是加粗权重。

除了 normal 和 bold 之外,font-weight 属性还支持以下值:

示例

要将文本加粗为中等粗细,可以使用以下 CSS:

p {  font-weight: 600;}

浏览器支持

font-weight 属性得到所有现代浏览器的良好支持。