SVG <testo>
Testo SVG - <testo>
L'elemento <text> viene utilizzato per definire un testo.
Esempio 1
Scrivi un testo:
Ecco il codice SVG:
Esempio
<svg height="30" width="200">
<text x="0" y="15" fill="red">I
love SVG!</text>
</svg>
Esempio 2
Ruota il testo:
Ecco il codice SVG:
Esempio
<svg height="60" width="200">
<text x="0" y="15" fill="red"
transform="rotate(30 20,40)">I
love SVG</text>
</svg>
Esempio 3
L'elemento <text> può essere organizzato in un numero qualsiasi di sottogruppi con l'elemento <tspan>. Ogni elemento <tspan> può contenere una formattazione e una posizione diverse.
Testo su più righe (con l'elemento <tspan>):
Ecco il codice SVG:
Esempio
<svg height="90" width="200">
<text x="10" y="20" style="fill:red;">Several lines:
<tspan x="10" y="45">First line.</tspan>
<tspan x="10" y="70">Second line.</tspan>
</text>
</svg>
Esempio 4
Testo come collegamento (con l'elemento <a>):
Ecco il codice SVG:
Esempio
<svg height="30" width="200"
xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href="https://www.w3schools.com/graphics/"
target="_blank">
<text x="0" y="15" fill="red">I love SVG!</text>
</a>
</svg>