aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/svg/attribute/letter-spacing/index.html
blob: 4f2568aebaf151670330a7b28436fa0c7fa8bbfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
title: letter-spacing
slug: Web/SVG/Attribute/letter-spacing
translation_of: Web/SVG/Attribute/letter-spacing
---
<div>{{SVGRef}}</div>

<p><span class="seoSummary">The <strong><code>letter-spacing</code></strong> attribute controls spacing between text characters, in addition to any spacing from the {{SVGAttr("kerning")}} attribute.</span></p>

<p>If the attribute value is a unitless number (like <code>128</code>), the browser processes it as a {{cssxref("length")}} in the current user coordinate system.</p>

<p>If the attribute value has a unit identifier, such as <code>.25em</code> or <code>1%</code>, then the browser converts the &lt;length&gt; into its corresponding value in the current user coordinate system.</p>

<p class="note"><strong>Note:</strong> As a presentation attribute, <code>letter-spacing</code> can be used as a CSS property. See the {{cssxref("letter-spacing", "CSS letter-spacing")}} property for more information.</p>

<p>As a presentation attribute, it can be applied to any element but it has effect only on the following eight elements: {{SVGElement("altGlyph")}}, {{SVGElement("text")}}, {{SVGElement("textPath")}}, {{SVGElement("tref")}}, and {{SVGElement("tspan")}}</p>

<div id="topExample">
<div class="hidden">
<pre class="brush: css">html, body, svg {
  height: 100%;
}</pre>
</div>

<pre class="brush: html; hightlight[2,3]">&lt;svg viewBox="0 0 400 30" xmlns="http://www.w3.org/2000/svg"&gt;
  &lt;text y="20" letter-spacing="2"&gt;Bigger letter-spacing&lt;/text&gt;
  &lt;text x="200" y="20" letter-spacing="-0.5"&gt;Smaller letter-spacing&lt;/text&gt;
&lt;/svg&gt;</pre>

<p>{{EmbedLiveSample("topExample", "200", "30")}}</p>
</div>

<h2 id="Usage_notes">Usage notes</h2>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row">Value</th>
   <td><code>normal</code> | {{cssxref("length")}}</td>
  </tr>
  <tr>
   <th scope="row">Default value</th>
   <td><code>normal</code></td>
  </tr>
  <tr>
   <th scope="row">Animatable</th>
   <td>Yes</td>
  </tr>
 </tbody>
</table>

<p>For a description of the values, please refer to the <a href="/en-US/docs/Web/CSS/letter-spacing#Values">CSS <code>letter-spacing</code></a> property.</p>

<p class="note">As of May 2019, Firefox <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=371787">ignores <code>letter-spacing</code></a> and renders text without.</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("CSS3 Text", "#letter-spacing-property", "letter-spacing")}}</td>
   <td>{{Spec2("CSS3 Text")}}</td>
   <td>SVG 2 just refers to the definition in CSS Text 3.</td>
  </tr>
  <tr>
   <td>{{SpecName("SVG1.1", "text.html#LetterSpacingProperty", "letter-spacing")}}</td>
   <td>{{Spec2("SVG1.1")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("svg.attributes.presentation.letter-spacing")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{cssxref("letter-spacing", "CSS letter-spacing")}}</li>
</ul>