SVG <texto>


Texto SVG - <texto>

O elemento <text> é usado para definir um texto.


Exemplo 1

Escreva um texto:

I love SVG! Sorry, your browser does not support inline SVG.

Segue o código SVG:

Exemplo

<svg height="30" width="200">
  <text x="0" y="15" fill="red">I love SVG!</text>
</svg>

Exemplo 2

Gire o texto:

I love SVG Sorry, your browser does not support inline SVG.

Segue o código SVG:

Exemplo

<svg height="60" width="200">
  <text x="0" y="15" fill="red" transform="rotate(30 20,40)">I love SVG</text>
</svg>


Exemplo 3

O elemento <text> pode ser organizado em qualquer número de subgrupos com o elemento <tspan>. Cada elemento <tspan> pode conter formatação e posição diferentes.

Texto em várias linhas (com o elemento <tspan>):

Several lines: First line. Second line. Sorry, your browser does not support inline SVG.

Segue o código SVG:

Exemplo

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

Exemplo 4

Texto como link (com o elemento <a>):

I love SVG! Sorry, your browser does not support inline SVG.

Segue o código SVG:

Exemplo

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