Open In App

SVG text Element

The SVG <text> element is used to draw text. There are some attributes to customize the text.

Syntax:



<text
  x="x-coordinates"
  y="y-coordinates"
  
  dx="list of lengths"
  dy="list of lengths"
  
  rotate="list of numbers"
  textlength="length"
  lengthAdjust="spacing" >
</text>

Attribute:

Example:






<html>
   <title>SVG Text</title>
   <body>
        
      <svg width="400" height="400">
            <text x="40" y="40" fill="green">
                  GeeksforGeeks
             </text>
      </svg>
     
   </body>
</html>

Output:

Example: Rotated multiline text.




<html>
   <title>SVG Text</title>
   <body>
        
      <svg width="400" height="400">
            <text x="10" y="10" fill="green"
                  transform="rotate(30 20, 40)">
              GeeksforGeeks</text>
            <text x="40" y="40" fill="green"
                  transform="rotate(90 10, 60)">
              GeeksforGeeks</text>
      </svg>
     
   </body>
</html>

Output:


Article Tags :