xml:space

  • Revision slug: SVG/Attribute/xml:space
  • Revision title: xml:space
  • Revision id: 41130
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment page created, 228 words added

Revision Content

« SVG Attribute reference home

SVG supports the standard XML attribute xml:space to specify the handling of white space characters within a given {{ SVGElement("text") }} element's character data. Note that any child element of a {{ SVGElement("text") }} element may also have an xml:space attribute which will apply to that child element's text content. Note that this attribute influence the way a browser should parse the xml content and therefor will change the way the DOM is built. It means that any change made to the value of this attribute through the DOM API may have no effect.

Usage context

Categories None
Value default | preserve
Animatable No
Normative document SVG 1.1 (2nd Edition)
default
The browser will remove all newline characters. Then it will convert all tab characters into space characters. Then, it will strip off all leading and trailing space characters. Then, all contiguous space characters will be consolidated.
preserve
The browser will will convert all newline and tab characters into space characters. Then, it will draw all space characters, including leading, trailing and multiple contiguous space characters. Thus, when drawn with xml:space="preserve", the string "a   b" (three spaces between "a" and "b") will produce a larger separation between "a" and "b" than "a b" (one space between "a" and "b").

Examples

Elements

All the SVG elements can use the xml:space attribute

Revision Source

<p>« <a href="/en/SVG/Attribute" title="en/SVG/Attribute">SVG Attribute reference home</a></p>
<p>SVG supports the standard XML attribute <code>xml:space</code> to specify the handling of white space characters within a given {{ SVGElement("text") }} element's character data. Note that any child element of a {{ SVGElement("text") }} element may also have an <code>xml:space</code> attribute which will apply to that child element's text content. Note that this attribute influence the way a browser should parse the xml content and therefor will change the way the DOM is built. It means that any change made to the value of this attribute through the DOM API may have no effect.</p>
<h2 id="Usage_context">Usage context</h2>
<table class="standard-table"> <tbody> <tr> <th scope="row">Categories</th> <td><em>None</em></td> </tr> <tr> <th scope="row">Value</th> <td><code><strong>default</strong></code> | <code>preserve</code></td> </tr> <tr> <th scope="row">Animatable</th> <td>No</td> </tr> <tr> <th scope="row">Normative document</th> <td><a class="external" href="http://www.w3.org/TR/SVG11/text.html#WhiteSpace" title="http://www.w3.org/TR/SVG11/text.html#WhiteSpace">SVG 1.1 (2nd Edition)</a></td> </tr> </tbody>
</table>
<dl> <dt>default</dt> <dd>The browser will remove all newline characters. Then it will convert all tab characters into space characters. Then, it will strip off all leading and trailing space characters. Then, all contiguous space characters will be consolidated.</dd> <dt>preserve</dt> <dd>The browser will will convert all newline and tab characters into space characters. Then, it will draw all space characters, including leading, trailing and multiple contiguous space characters. Thus, when drawn with <code>xml:space="preserve"</code>, the string "a   b" (three spaces between "a" and "b") will produce a larger separation between "a" and "b" than "a b" (one space between "a" and "b").</dd>
</dl>
<h2 id="Examples">Examples</h2>
<h2 id="Elements">Elements</h2>
<p>All the SVG elements can use the <code>xml:space</code> attribute</p>
Revert to this revision