--- title: tspan slug: Web/SVG/Element/tspan tags: - Conteúdo Textual - Elemento - Referencia - Referência(2) - SVG translation_of: Web/SVG/Element/tspan ---
{{SVGRef}}

O elemento SVG <tspan> define um subtexto dentro de um elemento {{SVGElement ('text')}} ou outro elemento <tspan>. Permite o ajuste do estilo e / ou posição desse subtexto, conforme necessário.

<svg viewBox="0 0 240 40" xmlns="http://www.w3.org/2000/svg">
  <style>
    text  { font: italic 12px serif; }
    tspan { font: bold 10px sans-serif; fill: red; }
  </style>

  <text x="10" y="30" class="small">
    You are
    <tspan>not</tspan>
    a banana!
  </text>
</svg>

{{EmbedLiveSample('Example', 100, '100%')}}

Attributes

{{SVGAttr("x")}}
The x coordinate of the starting point of the text baseline.
Value type: <length>|<percentage> ; Default value: none; Animatable: yes
{{SVGAttr("y")}}
The y coordinate of the starting point of the text baseline.
Value type: <length>|<percentage> ; Default value: none; Animatable: yes
{{SVGAttr("dx")}}
Shifts the text position horizontally from a previous text element.
Value type: <length>|<percentage> ; Default value: none; Animatable: yes
{{SVGAttr("dy")}}
Shifts the text position vertically from a previous text element.
Value type: <length>|<percentage> ; Default value: none; Animatable: yes
{{SVGAttr("rotate")}}
Rotates orientation of each individual glyph. Can rotate glyphs individually.
Value type: <list-of-number> ; Default value: none; Animatable: yes
{{SVGAttr("lengthAdjust")}}
How the text is stretched or compressed to fit the width defined by the textLength attribute.
Value type: spacing|spacingAndGlyphs; Default value: spacing; Animatable: yes
{{SVGAttr("textLength")}}
A width that the text should be scaled to fit.
Value type: <length>|<percentage> ; Default value: none; Animatable: yes

Global attributes

Core Attributes
Most notably: {{SVGAttr('id')}}, {{SVGAttr('tabindex')}}
Styling Attributes
{{SVGAttr('class')}}, {{SVGAttr('style')}}
Conditional Processing Attributes
Most notably: {{SVGAttr('requiredExtensions')}}, {{SVGAttr('systemLanguage')}}
Event Attributes
Global event attributes, Graphical event attributes
Presentation Attributes
Most notably: {{SVGAttr('clip-path')}}, {{SVGAttr('clip-rule')}}, {{SVGAttr('color')}}, {{SVGAttr('color-interpolation')}}, {{SVGAttr('color-rendering')}}, {{SVGAttr('cursor')}}, {{SVGAttr('display')}}, {{SVGAttr('dominant-baseline')}}, {{SVGAttr('fill')}}, {{SVGAttr('fill-opacity')}}, {{SVGAttr('fill-rule')}}, {{SVGAttr('filter')}}, {{SVGAttr('mask')}}, {{SVGAttr('opacity')}}, {{SVGAttr('pointer-events')}}, {{SVGAttr('shape-rendering')}}, {{SVGAttr('stroke')}}, {{SVGAttr('stroke-dasharray')}}, {{SVGAttr('stroke-dashoffset')}}, {{SVGAttr('stroke-linecap')}}, {{SVGAttr('stroke-linejoin')}}, {{SVGAttr('stroke-miterlimit')}}, {{SVGAttr('stroke-opacity')}}, {{SVGAttr('stroke-width')}}, {{SVGAttr('text-anchor')}}, {{SVGAttr("transform")}}, {{SVGAttr('vector-effect')}}, {{SVGAttr('visibility')}}
Aria Attributes
aria-activedescendant, aria-atomic, aria-autocomplete, aria-busy, aria-checked, aria-colcount, aria-colindex, aria-colspan, aria-controls, aria-current, aria-describedby, aria-details, aria-disabled, aria-dropeffect, aria-errormessage, aria-expanded, aria-flowto, aria-grabbed, aria-haspopup, aria-hidden, aria-invalid, aria-keyshortcuts, aria-label, aria-labelledby, aria-level, aria-live, aria-modal, aria-multiline, aria-multiselectable, aria-orientation, aria-owns, aria-placeholder, aria-posinset, aria-pressed, aria-readonly, aria-relevant, aria-required, aria-roledescription, aria-rowcount, aria-rowindex, aria-rowspan, aria-selected, aria-setsize, aria-sort, aria-valuemax, aria-valuemin, aria-valuenow, aria-valuetext, role

Usage notes

{{svginfo}}

Specifications

Specification Status Comment
{{SpecName('SVG2', 'text.html#TextElement', '<tspan>')}} {{Spec2('SVG2')}}
{{SpecName('SVG1.1', 'text.html#TSpanElement', '<tspan>')}} {{Spec2('SVG1.1')}} Initial definition

Compatibilidade com navegadores

{{Compat("svg.elements.tspan")}}