Skip to content

Commit 113213f

Browse files
committed
[css-text] Add in jdaggett's example code
--HG-- extra : rebase_source : 5537a01957e41bff2b1a89b94ed5596bc928631a
1 parent 39c8b1e commit 113213f

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

css-text/Overview.src.html

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

26+
.ls-ex {
27+
font-size: 200%;
28+
margin-left: 1em;
29+
}
30+
.ls-fixed-width {
31+
width: 10em;
32+
}
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; }
47+
2648
.char { border: 1px dotted gray; }
2749
.quarter { font-size: 25%; }
2850
tt[lang="ja"] { font-family: "MS Gothic", "Osaka", monospace }
@@ -2066,6 +2088,71 @@ <h3 id="letter-spacing">
20662088
<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>
20672089
</div>
20682090

2091+
<div class="example">
2092+
<p>The inline box used to define backgrounds and borders for a given element
2093+
only includes letter spacing between characters completely contained within that element:
2094+
2095+
<pre>
2096+
<!-- -->p { letter-spacing: 1em; }
2097+
2098+
<!-- -->&lt;p>a&lt;span>bb&lt;/span>c&lt;/p></pre>
2099+
2100+
<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>
2101+
2102+
<p>It is incorrect to include the letter spacing on the right or trailing edge of the element:
2103+
2104+
<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+
2106+
<p>Letter spacing is never applied at the beginning or end of a line:</p>
2107+
<pre>
2108+
<!-- -->p { letter-spacing: 1em; }
2109+
2110+
<!-- -->&lt;p>abc&lt;/p></pre>
2111+
2112+
<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>
2113+
<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>
2114+
2115+
<p>It is incorrect to append letter spacing to the trailing edge of lines:</p>
2116+
2117+
<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>
2118+
2119+
<p>A given value of 'letter-spacing' only affects the spacing
2120+
between characters completely contained within the element for which it is specified:
2121+
2122+
<pre>
2123+
<!-- -->p { letter-spacing: 1em; }
2124+
<!-- -->span { letter-spacing: 2em; }
2125+
2126+
<!-- -->&lt;p>a&lt;span>bb&lt;/span>c&lt;/p></pre>
2127+
2128+
<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>
2129+
2130+
<p>This also means that applying 'letter-spacing' to an element containing only a single character
2131+
has no effect on the rendered result:
2132+
2133+
<pre>
2134+
<!-- -->p { letter-spacing: 1em; }
2135+
<!-- -->span { letter-spacing: 2em; }
2136+
2137+
&lt;p>a&lt;span>b&lt;/span>c&lt;/p></pre>
2138+
2139+
<p class="ls-ex">a<span class="ls-1emsp"> </span><span class="ls-bg-border">b</span><span class="ls-1emsp"> </span>c</p>
2140+
2141+
<p>Letter spacing is inserted <strong>after</strong> RTL reordering,
2142+
so the letter spacing applied to the inner span below has no effect,
2143+
since after reordering the 'c' doesn't end up next to '&#x5d0;':
2144+
<pre>
2145+
<!-- -->p { letter-spacing: 1em; }
2146+
<!-- -->span { letter-spacing: 2em; }
2147+
2148+
<!-- -->&lt;!-- abc followed by Hebrew letters alef, bet and gimel
2149+
<!-- -->reordering will display these in reverse order --&gt;
2150+
<!-- -->&lt;p>ab&lt;span>c&amp;#x5d0;&lt;/span>&amp;#x5d1;&amp;#x5d2;&lt;/p>
2151+
<!-- -->&lt;span>b&lt;/span>c&lt;/p></pre>
2152+
2153+
<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>
2154+
</div>
2155+
20692156
<p>Letter-spacing ignores zero-width characters (such as those from the
20702157
Unicode Cf category). For example, 'letter-spacing' applied to
20712158
<code>A&amp;zwsp;B</code> is identical to <code>AB</code>.

0 commit comments

Comments
 (0)