--- title: text slug: Web/SVG/Element/text tags: - Conteúdo Textual - Elemento - Referencia - SVG translation_of: Web/SVG/Element/text --- <div>{{SVGRef}}</div> <p>O elemento SVG <code><strong><text></strong></code> desenha um elemento gráfico que consiste em texto. É possível aplicar um gradiente, pattern, clipping path, máscara ou filtro ao <code><text></code>, como qualquer outro elemento gráfico SVG.</p> <p>If text is included in SVG not inside of a <code><text></code> element, it is not rendered. This is different than being hidden by default, as setting the {{SVGAttr('display')}} property won't show the text.</p> <div id="Example"> <div class="hidden"> <pre class="brush: css">html,body,svg { height:100% }</pre> </div> <pre class="brush: html; highlight[8]"><svg viewBox="0 0 240 80" xmlns="http://www.w3.org/2000/svg"> <style> .small { font: italic 13px sans-serif; } .heavy { font: bold 30px sans-serif; } /* Note that the color of the text is set with the * * fill property, the color property is for HTML only */ .Rrrrr { font: italic 40px serif; fill: red; } </style> <text x="20" y="35" class="small">My</text> <text x="40" y="35" class="heavy">cat</text> <text x="55" y="55" class="small">is</text> <text x="65" y="55" class="Rrrrr">Grumpy!</text> </svg></pre> <p>{{EmbedLiveSample('Example', 100, '100%')}}</p> </div> <h2 id="Attributes">Attributes</h2> <dl> <dt>{{SVGAttr("x")}}</dt> <dd>The x coordinate of the starting point of the text baseline.<br> <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Length"><strong><length></strong></a>|<a href="/docs/Web/SVG/Content_type#Percentage"><strong><percentage></strong></a> ; <em>Default value</em>: <code>0</code>; <em>Animatable</em>: <strong>yes</strong></small></dd> <dt>{{SVGAttr("y")}}</dt> <dd>The y coordinate of the starting point of the text baseline.<br> <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Length"><strong><length></strong></a>|<a href="/docs/Web/SVG/Content_type#Percentage"><strong><percentage></strong></a> ; <em>Default value</em>: <code>0</code>; <em>Animatable</em>: <strong>yes</strong></small></dd> <dt>{{SVGAttr("dx")}}</dt> <dd>Shifts the text position horizontally from a previous text element.<br> <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Length"><strong><length></strong></a>|<a href="/docs/Web/SVG/Content_type#Percentage"><strong><percentage></strong></a> ; <em>Default value</em>: <em>none</em>; <em>Animatable</em>: <strong>yes</strong></small></dd> <dt>{{SVGAttr("dy")}}</dt> <dd>Shifts the text position vertically from a previous text element.<br> <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Length"><strong><length></strong></a>|<a href="/docs/Web/SVG/Content_type#Percentage"><strong><percentage></strong></a> ; <em>Default value</em>: <em>none</em>; <em>Animatable</em>: <strong>yes</strong></small></dd> <dt>{{SVGAttr("rotate")}}</dt> <dd>Rotates orientation of each individual glyph. Can rotate glyphs individually.<br> <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#List-of-Ts"><strong><list-of-number></strong></a> ; <em>Default value</em>: none; <em>Animatable</em>: <strong>yes</strong></small></dd> <dt>{{SVGAttr("lengthAdjust")}}</dt> <dd>How the text is stretched or compressed to fit the width defined by the <code>textLength</code> attribute.<br> <small><em>Value type</em>: <code>spacing</code>|<code>spacingAndGlyphs</code>; <em>Default value</em>: <code>spacing</code>; <em>Animatable</em>: <strong>yes</strong></small></dd> <dt>{{SVGAttr("textLength")}}</dt> <dd>A width that the text should be scaled to fit.<br> <small><em>Value type</em>: <a href="/docs/Web/SVG/Content_type#Length"><strong><length></strong></a>|<a href="/docs/Web/SVG/Content_type#Percentage"><strong><percentage></strong></a> ; <em>Default value</em>: <em>none</em>; <em>Animatable</em>: <strong>yes</strong></small></dd> </dl> <h3 id="Global_attributes">Global attributes</h3> <dl> <dt><a href="/docs/Web/SVG/Attribute/Core">Core Attributes</a></dt> <dd><small>Most notably: {{SVGAttr('id')}}, {{SVGAttr('tabindex')}}</small></dd> <dt><a href="/docs/Web/SVG/Attribute/Styling">Styling Attributes</a></dt> <dd><small>{{SVGAttr('class')}}, {{SVGAttr('style')}}</small></dd> <dt><a href="/docs/Web/SVG/Attribute/Conditional_Processing">Conditional Processing Attributes</a></dt> <dd><small>Most notably: {{SVGAttr('requiredExtensions')}}, {{SVGAttr('systemLanguage')}}</small></dd> <dt>Event Attributes</dt> <dd><small><a href="/docs/Web/SVG/Attribute/Events#Global_Event_Attributes">Global event attributes</a>, <a href="/docs/Web/SVG/Attribute/Events#Graphical_Event_Attributes">Graphical event attributes</a></small></dd> <dt><a href="/docs/Web/SVG/Attribute/Presentation">Presentation Attributes</a></dt> <dd><small>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')}}</small></dd> <dt>Aria Attributes</dt> <dd><small><code>aria-activedescendant</code>, <code>aria-atomic</code>, <code>aria-autocomplete</code>, <code>aria-busy</code>, <code>aria-checked</code>, <code>aria-colcount</code>, <code>aria-colindex</code>, <code>aria-colspan</code>, <code>aria-controls</code>, <code>aria-current</code>, <code>aria-describedby</code>, <code>aria-details</code>, <code>aria-disabled</code>, <code>aria-dropeffect</code>, <code>aria-errormessage</code>, <code>aria-expanded</code>, <code>aria-flowto</code>, <code>aria-grabbed</code>, <code>aria-haspopup</code>, <code>aria-hidden</code>, <code>aria-invalid</code>, <code>aria-keyshortcuts</code>, <code>aria-label</code>, <code>aria-labelledby</code>, <code>aria-level</code>, <code>aria-live</code>, <code>aria-modal</code>, <code>aria-multiline</code>, <code>aria-multiselectable</code>, <code>aria-orientation</code>, <code>aria-owns</code>, <code>aria-placeholder</code>, <code>aria-posinset</code>, <code>aria-pressed</code>, <code>aria-readonly</code>, <code>aria-relevant</code>, <code>aria-required</code>, <code>aria-roledescription</code>, <code>aria-rowcount</code>, <code>aria-rowindex</code>, <code>aria-rowspan</code>, <code>aria-selected</code>, <code>aria-setsize</code>, <code>aria-sort</code>, <code>aria-valuemax</code>, <code>aria-valuemin</code>, <code>aria-valuenow</code>, <code>aria-valuetext</code>, <code>role</code></small></dd> </dl> <h2 id="Usage_notes">Usage notes</h2> <p>{{svginfo}}</p> <h2 id="Specifications">Specifications</h2> <table class="standard-table"> <thead> <tr> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('SVG2', 'text.html#TextElement', '<text>')}}</td> <td>{{Spec2('SVG2')}}</td> <td></td> </tr> <tr> <td>{{SpecName('SVG1.1', 'text.html#TextElement', '<text>')}}</td> <td>{{Spec2('SVG1.1')}}</td> <td>Initial definition</td> </tr> </tbody> </table> <h2 id="Browser_compatibility">Compatibilidade com navegadores</h2> <p>{{Compat("svg.elements.text")}}</p> <h2 id="Related">Related</h2> <ul> <li>Other SVG text related elements: <strong>{{SVGElement("tspan")}}</strong>, {{SVGElement("tref")}}, {{SVGElement("altGlyph")}}</li> </ul>