Skip to content

Commit a8ad7ff

Browse files
committed
[css-text] Add in jdaggett's letter-spacing examples
1 parent 20a3306 commit a8ad7ff

2 files changed

Lines changed: 164 additions & 99 deletions

File tree

css-text/Overview.html

Lines changed: 113 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
rel=dcterms.rights>
1111
<meta content="CSS Text Module Level 3 (CSS3 Text)" name=dcterms.title>
1212
<meta content=text name=dcterms.type>
13-
<meta content=2013-06-18 name=dcterms.date>
13+
<meta content=2013-07-12 name=dcterms.date>
1414
<meta content="Elika J. Etemad" name=dcterms.creator>
1515
<meta content="Koji Ishii" name=dcterms.creator>
1616
<meta content=W3C name=dcterms.publisher>
@@ -34,6 +34,20 @@
3434
padding: 2px 0; }
3535
#letter-spacing-example span { border: 1px solid; }
3636

37+
/* Start Letter-spacing Tutorial */
38+
.ls-ex {
39+
font-size: 200%;
40+
margin-left: 1em;
41+
margin-right: 1em;
42+
}
43+
.ls-fixed-width {
44+
width: 10em;
45+
}
46+
.color-box { background: rgb(224, 203, 82); }
47+
.bad { color: red; }
48+
.good { color: green; }
49+
/* End Letter-spacing Tutorial */
50+
3751
.char { border: 1px dotted gray; }
3852
.quarter { font-size: 25%; }
3953
tt[lang="ja"] { font-family: "MS Gothic", "Osaka", monospace }
@@ -62,12 +76,12 @@
6276

6377
<h1>CSS Text Module Level 3</h1>
6478

65-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 18 June 2013</h2>
79+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 12 July 2013</h2>
6680

6781
<dl>
6882
<dt>This version:</dt>
6983
<!--
70-
<dd><a href="http://www.w3.org/TR/2013/WD-css3-text-20130618/">http://www.w3.org/TR/2013/WD-css3-text-20130618/</a></dd>
84+
<dd><a href="http://www.w3.org/TR/2013/WD-css3-text-20130712/">http://www.w3.org/TR/2013/WD-css3-text-20130712/</a></dd>
7185
-->
7286

7387
<dd><a
@@ -109,11 +123,11 @@ <h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 18 June 2013</h2>
109123

110124
<dd><a href="mailto:koji.a.ishii@mail.rakuten.com">Koji Ishii</a>
111125
(Rakuten, Inc.)
112-
113-
<dt>Test Suite:
114126

115-
<dd><a
116-
href="http://test.csswg.org/suites/css3-text/nightly-unstable/">http://test.csswg.org/suites/css3-text/nightly-unstable/</a>
127+
<dt>Test Suite:
128+
129+
<dd><a
130+
href="http://test.csswg.org/suites/css3-text/nightly-unstable/">http://test.csswg.org/suites/css3-text/nightly-unstable/</a>
117131
</dl>
118132
<!--begin-copyright-->
119133
<p class=copyright><a
@@ -2687,43 +2701,110 @@ <h3 id=letter-spacing><span class=secno>8.2. </span> Tracking: the ‘<a
26872701
href="http://lists.w3.org/Archives/Public/www-style/2013May/0280.html">this
26882702
thread</a>.
26892703

2704+
<p>For the purpose of ‘<a href="#letter-spacing0"><code
2705+
class=property>letter-spacing</code></a>’, each consecutive run of
2706+
atomic inlines (such as images and inline blocks) is treated as a single
2707+
<a href="#character"><i>character</i></a>.
2708+
26902709
<p>Letter-spacing must not be applied at the beginning or at the end of a
2691-
line. The total letter spacing between two adjacent <a
2692-
href="#character"><i>characters</i></a> (after bidi reordering) is
2693-
specified by and rendered within the innermost element that
2694-
<em>contains</em> the boundary between the two <a
2710+
line.
2711+
2712+
<div class=example>
2713+
<p>Because letter-spacing is not applied at the beginning or end of a
2714+
line, text always fits flush with the edge of the block.
2715+
2716+
<pre>
2717+
<!-- -->p { letter-spacing: 1em; }
2718+
2719+
<!-- -->&lt;p>abc&lt;/p></pre>
2720+
2721+
<p class="ls-ex good ls-fixed-width color-box"
2722+
style="text-align: left">a b c
2723+
2724+
<p class="ls-ex good ls-fixed-width color-box"
2725+
style="text-align: right">a b c
2726+
2727+
<p>UAs therefore must not append letter spacing to the right or trailing
2728+
edge of a line:
2729+
2730+
<p class="ls-ex bad ls-fixed-width color-box"
2731+
style="text-align: right">a b c 
2732+
</div>
2733+
2734+
<p> Letter spacing between two <a href="#character"><i>characters</i></a>
2735+
effectively “belongs” to the innermost element element that contains
2736+
the two <a href="#character"><i>characters</i></a>: the total letter
2737+
spacing between two adjacent <a href="#character"><i>characters</i></a>
2738+
(after bidi reordering) is specified by and rendered within the innermost
2739+
element that <em>contains</em> the boundary between the two <a
26952740
href="#character"><i>characters</i></a>.
26962741

2697-
<div class=example id=letter-spacing-example>
2698-
<p>For example, given the markup
2742+
<div class=example>
2743+
<p>A given value of ‘<a href="#letter-spacing0"><code
2744+
class=property>letter-spacing</code></a>’ only affects the spacing
2745+
between characters completely contained within the element for which it
2746+
is specified:
26992747

2700-
<pre><span class=P>&lt;P&gt;a<span class=LS>&lt;LS&gt;b<span
2701-
class=Z>&lt;Z&gt;cd&lt;/Z&gt;</span><span
2702-
class=Y>&lt;Y&gt;ef&lt;/Y&gt;</span>&lt;/LS&gt;</span>g&lt;/P&gt;</span></pre>
2748+
<pre>
2749+
<!-- -->p { letter-spacing: 1em; }
2750+
<!-- -->span { letter-spacing: 2em; }
27032751

2704-
<p>and the style sheet
2752+
<!-- -->&lt;p>a&lt;span>bb&lt;/span>c&lt;/p></pre>
27052753

2706-
<pre><!--
2707-
-->LS { letter-spacing: 1em; }
2708-
<!-- -->Z { letter-spacing: 0.3em; }
2709-
<!-- -->Y { letter-spacing: 0.4em; }</pre>
2754+
<p class=ls-ex>a <span class=color-box>b  b</span> c
2755+
2756+
<p>This also means that applying ‘<a href="#letter-spacing0"><code
2757+
class=property>letter-spacing</code></a>’ to an element containing only
2758+
a single character has no effect on the rendered result:
2759+
2760+
<pre>
2761+
<!-- -->p { letter-spacing: 1em; }
2762+
<!-- -->span { letter-spacing: 2em; }
2763+
2764+
<!-- -->&lt;p>a&lt;span>b&lt;/span>c&lt;/p></pre>
2765+
2766+
<p class=ls-ex>a <span class=color-box>b</span> c
2767+
2768+
<p>An inline box only includes letter spacing between characters
2769+
completely contained within that element:
2770+
2771+
<pre>
2772+
<!-- -->p { letter-spacing: 1em; }
2773+
2774+
<!-- -->&lt;p>a&lt;span>bb&lt;/span>c&lt;/p></pre>
2775+
2776+
<p class="ls-ex good">a <span class=color-box>b b</span> c
27102777

2711-
<p>the spacing would be as [noted] below:
2778+
<p>It is incorrect to include the letter spacing on the right or trailing
2779+
edge of the element:
27122780

2713-
<pre><span class=P>a[0]<span class=LS>b[1em]<span
2714-
class=Z>c[0.3em]d</span>[1em]<span
2715-
class=Y>e[0.4em]f</span></span>[0]g</span></pre>
2781+
<p class="ls-ex bad">a <span class=color-box>b b </span>c
2782+
2783+
<p>Letter spacing is inserted <strong>after</strong> RTL reordering, so
2784+
the letter spacing applied to the inner span below has no effect, since
2785+
after reordering the ‘<code class=property>c</code>’ doesn't end up
2786+
next to ‘<code class=css>א</code>’:
2787+
2788+
<pre>
2789+
<!-- -->p { letter-spacing: 1em; }
2790+
<!-- -->span { letter-spacing: 2em; }
2791+
2792+
<!-- -->&lt;!-- abc followed by Hebrew letters alef (א), bet (ב) and gimel (ג) -->
2793+
<!-- -->&lt;!-- Reordering will display these in reverse order. --&gt;
2794+
<!-- --><bdo
2795+
dir=ltr>&lt;p>ab&lt;span>cא&lt;/span>בג&lt;/p></bdo></pre>
2796+
2797+
<p class=ls-ex>a b <span class=color-box>c</span><span
2798+
class=color-box>א</span> ב ג
27162799
</div>
27172800

27182801
<p>Letter-spacing ignores zero-width characters (such as those from the
2719-
Unicode Cf category). For example, ‘<a href="#letter-spacing0"><code
2720-
class=property>letter-spacing</code></a>’ applied to
2721-
<code>A&amp;zwsp;B</code> is identical to <code>AB</code>.
2802+
Unicode Cf category).
27222803

2723-
<p>For the purpose of<a href="#letter-spacing0"><code
2724-
class=property>letter-spacing</code></a>, each consecutive run of
2725-
atomic inlines (such as images and inline blocks) is treated as a single
2726-
<a href="#character"><i>character</i></a>.
2804+
<p class=example>For example,<a href="#letter-spacing0"><code
2805+
class=property>letter-spacing</code></a> applied to
2806+
<code>A&amp;zwsp;B</code> is identical to <code>AB</code>, regardless of
2807+
where any element boundaries might fall.
27272808

27282809
<p>When the effective letter-spacing between two characters is not zero
27292810
(due to either <a href="#text-justify">justification</a> or non-zero

css-text/Overview.src.html

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,19 @@
2323
padding: 2px 0; }
2424
#letter-spacing-example span { border: 1px solid; }
2525

26+
/* Start Letter-spacing Tutorial */
2627
.ls-ex {
2728
font-size: 200%;
2829
margin-left: 1em;
30+
margin-right: 1em;
2931
}
3032
.ls-fixed-width {
3133
width: 10em;
3234
}
33-
.ls-right {
34-
text-align: right;
35-
}
36-
.ls-1emsp {
37-
display: inline-block;
38-
width: 1em;
39-
}
40-
.ls-2emsp {
41-
display: inline-block;
42-
width: 2em;
43-
}
44-
.ls-bg-border { background-color: rgb(224, 203, 82); }
45-
.ls-1em { letter-spacing: 1em; }
46-
.ls-2em { letter-spacing: 1em; }
35+
.color-box { background: rgb(224, 203, 82); }
36+
.bad { color: red; }
37+
.good { color: green; }
38+
/* End Letter-spacing Tutorial */
4739

4840
.char { border: 1px dotted gray; }
4941
.quarter { font-size: 25%; }
@@ -2070,77 +2062,71 @@ <h3 id="letter-spacing">
20702062
German, for example, avoids letter-spacing for justification because it's used for emphasis.
20712063
See <a href="http://lists.w3.org/Archives/Public/www-style/2013May/0280.html">this thread</a>.
20722064

2065+
<p>For the purpose of 'letter-spacing', each consecutive run of atomic
2066+
inlines (such as images and inline blocks) is treated as a single
2067+
<i>character</i>.
2068+
20732069
<p>Letter-spacing must not be applied at the beginning or at the end of a line.
2074-
The total letter spacing between two adjacent <i>characters</i> (after bidi reordering)
2075-
is specified by and rendered within
2076-
the innermost element that <em>contains</em> the boundary between the two <i>characters</i>.
20772070

2078-
<div class="example" id="letter-spacing-example">
2079-
<p>For example, given the markup</p>
2071+
<div class="example">
2072+
<p>Because letter-spacing is not applied at the beginning or end of a line,
2073+
text always fits flush with the edge of the block.
2074+
<pre>
2075+
<!-- -->p { letter-spacing: 1em; }
20802076

2081-
<pre><span class="P">&lt;P&gt;a<span class="LS">&lt;LS&gt;b<span class="Z">&lt;Z&gt;cd&lt;/Z&gt;</span><span class="Y">&lt;Y&gt;ef&lt;/Y&gt;</span>&lt;/LS&gt;</span>g&lt;/P&gt;</span></pre>
2077+
<!-- -->&lt;p>abc&lt;/p></pre>
20822078

2083-
<p>and the style sheet</p>
2079+
<p class="ls-ex good ls-fixed-width color-box" style="text-align: left">a&emsp;b&emsp;c</p>
2080+
<p class="ls-ex good ls-fixed-width color-box" style="text-align: right">a&emsp;b&emsp;c</p>
20842081

2085-
<pre><!--
2086-
-->LS { letter-spacing: 1em; }
2087-
<!-- -->Z { letter-spacing: 0.3em; }
2088-
<!-- -->Y { letter-spacing: 0.4em; }</pre>
2082+
<p>UAs therefore must not append letter spacing to the right or trailing edge of a line:</p>
20892083

2090-
<p>the spacing would be as [noted] below:</p>
2084+
<p class="ls-ex bad ls-fixed-width color-box" style="text-align: right">a&emsp;b&emsp;c&emsp;</p>
2085+
</div>
20912086

2092-
<pre><span class="P">a[0]<span class="LS">b[1em]<span class="Z">c[0.3em]d</span>[1em]<span class="Y">e[0.4em]f</span></span>[0]g</span></pre>
2093-
</div>
2087+
Letter spacing between two <i>characters</i> effectively “belongs”
2088+
to the innermost element element that contains the two <i>characters</i>:
2089+
the total letter spacing between two adjacent <i>characters</i> (after bidi reordering)
2090+
is specified by and rendered within
2091+
the innermost element that <em>contains</em> the boundary between the two <i>characters</i>.
20942092

20952093
<div class="example">
2096-
<p>The inline box used to define backgrounds and borders for a given element
2097-
only includes letter spacing between characters completely contained within that element:
2098-
2094+
<p>A given value of 'letter-spacing' only affects the spacing
2095+
between characters completely contained within the element for which it is specified:
2096+
20992097
<pre>
21002098
<!-- -->p { letter-spacing: 1em; }
2099+
<!-- -->span { letter-spacing: 2em; }
21012100

21022101
<!-- -->&lt;p>a&lt;span>bb&lt;/span>c&lt;/p></pre>
21032102

2104-
<p class="ls-ex good">a<span class="ls-1emsp"> </span><span class="ls-bg-border">b<span class="ls-1emsp"> </span>b</span><span class="ls-1emsp"> </span>c</p>
2103+
<p class="ls-ex">a&emsp;<span class="color-box">b&emsp;&emsp;b</span>&emsp;c</p>
21052104

2106-
<p>It is incorrect to include the letter spacing on the right or trailing edge of the element:
2107-
2108-
<p class="ls-ex bad">a<span class="ls-1emsp"> </span><span class="ls-bg-border">b<span class="ls-1emsp"> </span>b<span class="ls-1emsp"> </span></span>c</p>
2105+
<p>This also means that applying 'letter-spacing' to
2106+
an element containing only a single character
2107+
has no effect on the rendered result:
21092108

2110-
<p>Letter spacing is never applied at the beginning or end of a line:</p>
21112109
<pre>
21122110
<!-- -->p { letter-spacing: 1em; }
2111+
<!-- -->span { letter-spacing: 2em; }
21132112

2114-
<!-- -->&lt;p>abc&lt;/p></pre>
2115-
2116-
<p class="ls-ex good ls-fixed-width ls-bg-border">a<span class="ls-1emsp"> </span>b<span class="ls-1emsp"> </span>c</p>
2117-
<p class="ls-ex good ls-fixed-width ls-bg-border ls-right">a<span class="ls-1emsp"> </span>b<span class="ls-1emsp"> </span>c</p>
2118-
2119-
<p>It is incorrect to append letter spacing to the trailing edge of lines:</p>
2113+
<!-- -->&lt;p>a&lt;span>b&lt;/span>c&lt;/p></pre>
21202114

2121-
<p class="ls-ex bad ls-fixed-width ls-bg-border ls-right">a<span class="ls-1emsp"> </span>b<span class="ls-1emsp"> </span>c<span class="ls-1emsp"> </span></p>
2115+
<p class="ls-ex">a&emsp;<span class="color-box">b</span>&emsp;c</p>
21222116

2123-
<p>A given value of 'letter-spacing' only affects the spacing
2124-
between characters completely contained within the element for which it is specified:
2117+
<p>An inline box only includes
2118+
letter spacing between characters completely contained within that element:
21252119

21262120
<pre>
21272121
<!-- -->p { letter-spacing: 1em; }
2128-
<!-- -->span { letter-spacing: 2em; }
21292122

21302123
<!-- -->&lt;p>a&lt;span>bb&lt;/span>c&lt;/p></pre>
21312124

2132-
<p class="ls-ex">a<span class="ls-1emsp"> </span><span class="ls-bg-border">b<span class="ls-2emsp"> </span>b</span><span class="ls-1emsp"> </span>c</p>
2133-
2134-
<p>This also means that applying 'letter-spacing' to an element containing only a single character
2135-
has no effect on the rendered result:
2136-
2137-
<pre>
2138-
<!-- -->p { letter-spacing: 1em; }
2139-
<!-- -->span { letter-spacing: 2em; }
2125+
<p class="ls-ex good">a&emsp;<span class="color-box">b&emsp;b</span>&emsp;c</p>
21402126

2141-
&lt;p>a&lt;span>b&lt;/span>c&lt;/p></pre>
2127+
<p>It is incorrect to include the letter spacing on the right or trailing edge of the element:
21422128

2143-
<p class="ls-ex">a<span class="ls-1emsp"> </span><span class="ls-bg-border">b</span><span class="ls-1emsp"> </span>c</p>
2129+
<p class="ls-ex bad">a&emsp;<span class="color-box">b&emsp;b&emsp;</span>c</p>
21442130

21452131
<p>Letter spacing is inserted <strong>after</strong> RTL reordering,
21462132
so the letter spacing applied to the inner span below has no effect,
@@ -2149,21 +2135,19 @@ <h3 id="letter-spacing">
21492135
<!-- -->p { letter-spacing: 1em; }
21502136
<!-- -->span { letter-spacing: 2em; }
21512137

2152-
<!-- -->&lt;!-- abc followed by Hebrew letters alef, bet and gimel
2153-
<!-- -->reordering will display these in reverse order --&gt;
2154-
<!-- -->&lt;p>ab&lt;span>c&amp;#x5d0;&lt;/span>&amp;#x5d1;&amp;#x5d2;&lt;/p>
2155-
<!-- -->&lt;span>b&lt;/span>c&lt;/p></pre>
2138+
<!-- -->&lt;!-- abc followed by Hebrew letters alef (&#x5d0;), bet (&#x5d1;) and gimel (&#x5d2;) -->
2139+
<!-- -->&lt;!-- Reordering will display these in reverse order. --&gt;
2140+
<!-- --><bdo dir=ltr>&lt;p>ab&lt;span>c&#x5d0;&lt;/span>&#x5d1;&#x5d2;&lt;/p></bdo></pre>
21562141

2157-
<p class="ls-ex">a<span class="ls-1emsp"> </span>b</span><span class="ls-1emsp"> </span><span class="ls-bg-border">c</span><span class="ls-1emsp"> </span><span class="ls-bg-border">&#x5d0;</span><span class="ls-1emsp"> </span>&#x5d1;<span class="ls-1emsp"> </span>&#x5d2;</p>
2142+
<p class="ls-ex">a&emsp;b</span>&emsp;<span class="color-box">c</span>&emsp;<span class="color-box">&#x5d0;</span>&emsp;&#x5d1;&emsp;&#x5d2;</p>
21582143
</div>
21592144

21602145
<p>Letter-spacing ignores zero-width characters (such as those from the
2161-
Unicode Cf category). For example, 'letter-spacing' applied to
2162-
<code>A&amp;zwsp;B</code> is identical to <code>AB</code>.
2163-
2164-
<p>For the purpose of 'letter-spacing', each consecutive run of atomic
2165-
inlines (such as images and inline blocks) is treated as a single
2166-
<i>character</i>.
2146+
Unicode Cf category).
2147+
2148+
<p class="example">For example, 'letter-spacing' applied to
2149+
<code>A&amp;zwsp;B</code> is identical to <code>AB</code>,
2150+
regardless of where any element boundaries might fall.
21672151

21682152
<p>When the effective letter-spacing between two characters is not zero
21692153
(due to either <a href="#text-justify">justification</a>

0 commit comments

Comments
 (0)