SVG <text>
- Previous Page SVG Path
- Next Page SVG Stroke
SVG Text - <text>
<text>
elements are used to define text.
Example 1
Write a text:
This is the SVG code:
<svg height="30" width="200"> <text x="0" y="15" fill="red">I love SVG!</text> </svg>
Example 2
Rotated text:
This is the SVG code:
<svg height="60" width="200"> <text x="0" y="15" fill="red" transform="rotate(30 20,40)">I love SVG</text> </svg>
Example 3
<text>
element can be combined with <tspan>
elements together, are arranged in any number of subgroups. Each <tspan>
elements can contain different formats and positions.
Multi-line text (using <tspan> element):
This is the SVG code:
<svg height="90" width="200"> <text x="10" y="20" style="fill:red;">Several lines:</text> <tspan x="10" y="45">First line.</tspan> <tspan x="10" y="70">Second line.</tspan> </text> </svg>
Example 4
As link text (with <a>
element):
This is the SVG code:
<svg height="30" width="200" xmlns:xlink="http://www.w3.org/1999/xlink"> <a xlink:href="www.codew3c.com/graphics/index.asp" target="_blank"> <text x="0" y="15" fill="red">I love SVG!</text> </a> </svg>
- Previous Page SVG Path
- Next Page SVG Stroke