SVG <text>

Texto SVG - <text>

<text> O elemento é usado para definir texto.

exemplo 1

Escreva um texto:

Eu amo SVG!

Este é o código SVG:

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

Experimente por Si Mesmo

exemplo 2

Texto rotacionado:

Eu amo SVG

Este é o código SVG:

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

Experimente por Si Mesmo

exemplo 3

<text> elemento pode ser <tspan> elementos juntos, organizados em qualquer número de subgrupos. Cada <tspan> O elemento pode conter diferentes formatos e posições.

Texto de várias linhas (usando o elemento <tspan>):

Linhas várias: Primeira linha. Segunda linha.

Este é o código SVG:

<svg height="90" width="200">
  <text x="10" y="20" style="fill:red;">Linhas várias:</text>
    <tspan x="10" y="45">Primeira linha.</tspan>
    <tspan x="10" y="70">Segunda linha.</tspan>
  </text>
</svg>

Experimente por Si Mesmo

exemplo 4

como texto de link (com <a> elemento):

Eu amo SVG!

Este é o código SVG:

<svg height="30" width="200" xmlns:xlink="http://www.w3.org/1999/xlink">
  <a xlink:href="www.codew3c.com/graphics/index.asp" target="_blank">
    <text x="0" y="15" fill="red">Eu amo SVG!</text>
  </a>
</svg>

Experimente por Si Mesmo