The Wayback Machine - https://web.archive.org/web/20240204103345/https://www.geeksforgeeks.org/svg-text-element/
Open In App
Related Articles

SVG text Element

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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:

  • x: x axis coordinates of glyphs.
  • y: y axis coordinates of glyphs.
  • dx: shift along with x-axis.
  • dy: shift along with y-axis.
  • rotate: rotation of glyphs.
  • textlength: render text’s length.
  • lengthAdjust: adjustments with the rendered length.

Example:

html




<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




<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:


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Looking for a place to share your ideas, learn, and connect? Our Community portal is just the spot! Come join us and see what all the buzz is about!


Last Updated : 31 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials