Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
<tspan>

The <tspan> element defines a sub-string or sub-group of text that can be independently positioned or styled inside an SVG text flow.

Common usage includes changing the color, weight, or position of a portion of text within a <text> element.

A <tspan> is a text run nested inside a <text> (or inside another <tspan>) - very similar in spirit to how HTML's <span> subdivides a <p>. Any text that isn't wrapped in a <tspan> simply inherits the parent <text>'s styling; wrapping a portion in <tspan> lets you override properties like fill, font-weight, or font-size, or explicitly move that portion using the per-glyph positioning attributes x, y, dx, dy, and rotate. Donner also supports the SVG text-length calibration attributes textLength and lengthAdjust on <tspan> runs. <tspan> does not exist on its own - it must always be a descendant of <text>.

<text x="20" y="40">
You are
<tspan dx="10" fill="red" font-weight="bold">
NOT
</tspan>
a banana.
</text>

You are NOT a banana.

Attribute Default Description
x (none) Absolute X position(s); if omitted, the surrounding text position continues
y (none) Absolute Y position(s); if omitted, the surrounding text position continues
dx (none) Relative X shift(s) for glyphs
dy (none) Relative Y shift(s) for glyphs
rotate (none) Rotation(s) for each glyph in degrees
textLength (none) Author-specified total advance length for this run
lengthAdjust spacing spacing or spacingAndGlyphs adjustment mode