Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
<textPath>

The <textPath> element renders text along an arbitrary path, given either inline with the SVG 2 path attribute or by reference with href.

It must be a child of a <text> element.

A <textPath> lets text flow along the curve of any <path> instead of in a straight horizontal line - think of a label hugging the edge of a circle, a headline bent along a wave, or caption text tracking the outline of a shape. Write the geometry directly in the path attribute, or reference a shape by its id with href, and SVG lays out each glyph along that geometry, automatically rotating it to follow the local tangent. The startOffset attribute controls where along the path the text begins, allowing fine adjustment or animation.

<textPath> must always live inside a <text> element; it cannot be used on its own.

Text flows along the path

<defs>
<path id="myPath" d="M 20 110 Q 160 -10 300 110" fill="none"/>
</defs>
<text font-size="22">
<textPath href="#myPath">Text flows along the path</textPath>
</text>
Attribute Default Description
path (none) Path data laid out in this element's own user space. Takes precedence over href.
href (none) Reference to a <path> or any basic shape, whose equivalent path is used. Supplies the geometry when path is absent or yields none.
startOffset 0 Offset along the path where text begins
method align align places each glyph rigidly on the tangent. stretch asks for warped glyph outlines, which is parsed but rendered as align.
side left left or right. right places text on the other side by reversing the direction of travel.
spacing exact exact advances glyphs by their shaped widths. auto leaves the choice to the user agent, and Donner chooses the same spacing as exact.
Note
The parser accepts x, y, dx, dy, and rotate on <textPath> for DOM fidelity, but text layout intentionally ignores those attributes on the <textPath> element itself, matching the SVG text model. Apply positioning to the parent <text> or nested <tspan> content instead.