Can text be added to an SVG path?

Is it possible to add text to an svg path, I have created a svg triangle and would like to add a letter to the center of this but not sure if this is possible?



Yes. See section 10.13 of the SVG1.1 specification (titled "Text on a path") for information on using the textPath element.


  1. Give your path an id attribute.
  2. Create <textPath xlink:href="#pathid">My text here</textPath>

Here's an example straight from the spec:

SVG Image with text following the curve of the path with ID "MyPath"

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
<svg width="12cm" height="3.6cm" viewBox="0 0 1000 300" version="1.1"
    <path id="MyPath"
          d="M 100 200 
             C 200 100 300   0 400 100
             C 500 200 600 300 700 200
             C 800 100 900 100 900 100" />
  <desc>Example toap01 - simple text on a path</desc>

  <use xlink:href="#MyPath" fill="none" stroke="red"  />
  <text font-family="Verdana" font-size="42.5" fill="blue" >
    <textPath xlink:href="#MyPath">
      We go up, then we go down, then up again



Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.