I am trying to add text next to parts of an svg image image.
Here is my html
<svg id = "svgelem" width = "300" height = "300" xmlns = "http://www.w3.org/2000/svg">
<polygon points="100,10 40,180 190,60 10,60 160,180" fill="blue"/>
</svg>
Here is what I want it to look like
How do I do this? I am new to working with svgs
2
Answers
Going with Robert Longson‘s suggestion, here you have it:
Within the
<SVG></SVG>
block, you can add text using the<TEXT>
tag. For details, I look at W3C schools or the Mozilla docs.TEXT in Mozilla Developer Docs
Basically, the TEXT tag lets you type the text and style it. I use it for adding callouts to screen shots in documentation. The X and Y values position the text on the SVG "canvas". I put a white box with a red border behind the text. Here is an example of the HTML: