此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

font-weight

基线 广泛可用

自 2015年7月 起,此特性已在主流浏览器中得到支持,可在大多数设备和浏览器版本中正常使用。

font-weight 属性表示用于渲染文本的字形相对于同一字体家族中其他字体的粗细程度。

备注:作为表现属性,font-weight 也有一个对应的 CSS 属性:font-weight。当两者都被指定时,CSS 属性优先。

你可以将此属性与以下 SVG 元素一起使用:

示例

控制 SVG 粗细

html
<svg viewBox="0 0 200 30" xmlns="http://www.w3.org/2000/svg">
  <text y="20" font-weight="normal">正常文本</text>
  <text x="100" y="20" font-weight="bold">粗体文本</text>
</svg>

使用说明

normal | bold | bolder | lighter | <number>
默认值 normal
动画性

有关各值的说明,请参阅 CSS font-weight 属性。

规范

规范
CSS Fonts Module Level 4
# font-weight-prop

浏览器兼容性

参见