|
23 | 23 | padding: 2px 0; } |
24 | 24 | #letter-spacing-example span { border: 1px solid; } |
25 | 25 |
|
| 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 | + |
26 | 48 | .char { border: 1px dotted gray; } |
27 | 49 | .quarter { font-size: 25%; } |
28 | 50 | tt[lang="ja"] { font-family: "MS Gothic", "Osaka", monospace } |
@@ -2066,6 +2088,71 @@ <h3 id="letter-spacing"> |
2066 | 2088 | <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> |
2067 | 2089 | </div> |
2068 | 2090 |
|
| 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 | +<!-- --><p>a<span>bb</span>c</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 | +<!-- --><p>abc</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 | +<!-- --><p>a<span>bb</span>c</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 | + <p>a<span>b</span>c</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 'א': |
| 2144 | + <pre> |
| 2145 | +<!-- -->p { letter-spacing: 1em; } |
| 2146 | +<!-- -->span { letter-spacing: 2em; } |
| 2147 | + |
| 2148 | +<!-- --><!-- abc followed by Hebrew letters alef, bet and gimel |
| 2149 | +<!-- -->reordering will display these in reverse order --> |
| 2150 | +<!-- --><p>ab<span>c&#x5d0;</span>&#x5d1;&#x5d2;</p> |
| 2151 | +<!-- --><span>b</span>c</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">א</span><span class="ls-1emsp"> </span>ב<span class="ls-1emsp"> </span>ג</p> |
| 2154 | + </div> |
| 2155 | + |
2069 | 2156 | <p>Letter-spacing ignores zero-width characters (such as those from the |
2070 | 2157 | Unicode Cf category). For example, 'letter-spacing' applied to |
2071 | 2158 | <code>A&zwsp;B</code> is identical to <code>AB</code>. |
|
0 commit comments