The SVG <text> element defines a graphics element consisting of text. It's possible to apply a gradient, pattern, clipping path, mask, or filter to <text>, just like any other SVG graphics element.

If text is included within SVG not inside of a <text> element, it is not rendered. This is different from being hidden by default, as setting the display property will not show the text.

Usage context

CategoriesGraphics element, Text content element
Permitted contentCharacter data and any number of the following elements, in any order:
Animation elements
Descriptive elements
Text content elements
<a>

Attributes

Global attributes

Specific attributes

DOM Interface

This element implements the SVGTextElement interface.

Examples

Basic text usage

SVG

<svg xmlns="http://www.w3.org/2000/svg"
     width="500" height="40" viewBox="0 0 500 40">

  <text x="0" y="35" font-family="Verdana" font-size="35">
    Hello, out there
  </text>
</svg>

Result

Rotated text

SVG text can be rotated.

SVG

<svg xmlns="http://www.w3.org/2000/svg" width="180" height="120">
  <text x="0" y="20" transform="rotate(30 20,40)">
    SVG Text Rotation example
  </text>
</svg>

Result

Colored text

SVG text can be colored.

SVG

<svg xmlns="http://www.w3.org/2000/svg" width="200" height="30">
  <text x="10" y="20" stroke="none" fill="red">
    SVG Colored Text
  </text>
</svg>

Result

Styling text via CSS

SVG text can be styled like HTML text.

SVG

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="60">
  <text x="10" y="40"
      style="font-family: Times New Roman;
             font-size: 44px;
             stroke: #00ff00;
             fill: #0000ff;">
    SVG text styling
  </text>
</svg>

Result

Specifications

Specification Status Comment
Scalable Vector Graphics (SVG) 2
The definition of '<text>' in that specification.
Candidate Recommendation  
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of '<text>' in that specification.
Recommendation Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support1121.5983
dx Yes12 Yes Yes Yes Yes
dy Yes12 Yes Yes Yes Yes
lengthAdjust Yes12 Yes Yes Yes Yes
rotate Yes12 Yes Yes Yes Yes
textLength Yes12 Yes Yes Yes Yes
x Yes12 Yes Yes Yes Yes
y Yes12 Yes Yes Yes Yes
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support3 Yes Yes4 Yes3 ?
dx Yes Yes Yes Yes Yes Yes ?
dy Yes Yes Yes Yes Yes Yes ?
lengthAdjust Yes Yes Yes Yes Yes Yes ?
rotate Yes Yes Yes Yes Yes Yes ?
textLength Yes Yes Yes Yes Yes Yes ?
x Yes Yes Yes Yes Yes Yes ?
y Yes Yes Yes Yes Yes Yes ?

Document Tags and Contributors

Last updated by: fscholz,