W3cubDocs

/SVG

<tspan>

Within a <text> element, text and font properties and the current text position can be adjusted with absolute or relative coordinate values by including a <tspan> element.

Usage context

Categories Text content element, Text content child element
Permitted content Character data and any number of the following elements, in any order:
Descriptive elements
<a>, <altGlyph>, <animate>, <animateColor>, <set>, <tref>, <tspan>

Attributes

Global attributes

Specific attributes

DOM Interface

This element implements the SVGTSpanElement interface.

Example

SVG

<?xml version="1.0"?>
<svg width="250" height="40" viewBox="0 0 250 40"
    xmlns="http://www.w3.org/2000/svg" version="1.1">

  <style>
<![CDATA[
text{
  font: 20px Verdana, Helvetica, Arial, sans-serif;
}

tspan{
  fill: red;
  font-weight: bold
}
]]>
  </style>

  <text x="15" y="30">
    You are 
    <tspan>not</tspan> 
    a banana
  </text>
</svg>

Result

Specifications

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 1 Yes 1.5 9 9 3
dx Yes Yes Yes Yes Yes Yes
dy Yes Yes Yes Yes Yes Yes
lengthAdjust ? ? ? ? ? ?
rotate Yes ? No ? Yes Yes
textLength Yes Yes Yes Yes Yes Yes
x Yes Yes Yes Yes Yes Yes
y Yes Yes Yes Yes Yes Yes
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 3 Yes Yes 4 Yes 3 ?
dx Yes Yes Yes Yes Yes Yes ?
dy Yes Yes Yes Yes Yes Yes ?
lengthAdjust ? ? ? ? ? ? ?
rotate Yes Yes ? No ? Yes ?
textLength Yes Yes Yes Yes Yes Yes ?
x Yes Yes Yes Yes Yes Yes ?
y Yes Yes Yes Yes Yes Yes ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/tspan