Back to Content

font-weight

files/en-us/web/svg/reference/attribute/font-weight/index.md

latest1.4 KB
Original Source

The font-weight attribute refers to the boldness or lightness of the glyphs used to render the text, relative to other fonts in the same font family.

[!NOTE] As a presentation attribute, font-weight also has a CSS property counterpart: {{cssxref("font-weight")}}. When both are specified, the CSS property takes priority.

You can use this attribute with the following SVG elements:

  • {{SVGElement("text")}}
  • {{SVGElement("textPath")}}
  • {{SVGElement("tspan")}}

Examples

Controlling SVG font weight

html
<svg viewBox="0 0 200 30" xmlns="http://www.w3.org/2000/svg">
  <text y="20" font-weight="normal">Normal text</text>
  <text x="100" y="20" font-weight="bold">Bold text</text>
</svg>

{{EmbedLiveSample}}

Usage notes

<table class="properties"> <tbody> <tr> <th scope="row">Value</th> <td> <code>normal</code> | <code>bold</code> | <code>bolder</code> | <code>lighter</code> | {{cssxref("number")}} </td> </tr> <tr> <th scope="row">Default value</th> <td><code>normal</code></td> </tr> <tr> <th scope="row">Animatable</th> <td>Yes</td> </tr> </tbody> </table>

For a description of the values, please refer to the CSS font-weight property.

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • CSS {{cssxref("font-weight")}} property