css-writing-modes/Overview.src.html

Tue, 16 Jul 2013 16:29:52 -0700

author
fantasai <fantasai.cvs@inkedblade.net>
date
Tue, 16 Jul 2013 16:29:52 -0700
changeset 8705
9a46d52c3a86
parent 8678
2369a5ba443d
child 8706
92aa893ac8ca
permissions
-rwxr-xr-x

[css-writing-modes] Require hwid/twid/qwid for OT implementations of TCY compression when they are available for all characters in the composition

kojiishi@5775 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
fantasai@365 2 <html lang="en">
fantasai@365 3 <head>
fantasai@1767 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
fantasai@1969 5 <title>CSS Writing Modes Module Level 3</title>
fantasai@4174 6 <link rel="stylesheet" type="text/css" href="../default.css">
fantasai@2058 7 <style type="text/css">
fantasai@2058 8 object { vertical-align: middle; }
fantasai@2058 9 .sidebar { float: right; background: #eee; border: solid gray; margin: 1em; }
fantasai@2058 10 .sidebar .figure { margin: 1em; }
fantasai@2058 11 .sidebar object { margin: 0 auto; display: block; }
fantasai@2097 12 .figurepair { display: table; margin: 1em auto; }
fantasai@2097 13 .figurepair .figure { display: table-cell; }
fantasai@2190 14 h2, .example { clear: both; }
fantasai@2731 15 .figure img,
fantasai@2731 16 .figure object,
fantasai@2902 17 .example img,
fantasai@2901 18 dd img { max-width: 100%; display: block; margin: 1em auto; }
kojiishi@3043 19 div.figure table {
kojiishi@3043 20 margin:auto;
kojiishi@3043 21 }
fantasai@2058 22 </style>
bert@3413 23 <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-ED.css">
rhauck@8359 24 <script src='http://test.csswg.org/harness/annotate.js#CSS3-WRITING-MODES_DEV' type='text/javascript' defer></script>
fantasai@365 25 </head>
fantasai@365 26
fantasai@365 27 <body>
fantasai@365 28
fantasai@365 29 <div class="head">
fantasai@365 30
fantasai@365 31 <!--logo-->
fantasai@365 32
fantasai@1969 33 <h1>CSS Writing Modes Module Level 3</h1>
fantasai@365 34
fantasai@1767 35 <h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
fantasai@365 36 <dl>
fantasai@365 37 <dt>This version:</dt>
fantasai@5999 38 <dd><a href="http://dev.w3.org/csswg/css3-writing-modes/">http://dev.w3.org/csswg/css3-writing-modes/</a>
fantasai@5659 39 <!--
fantasai@5999 40 <dd><a href="http://www.w3.org/TR/[YEAR]/WD-[SHORTNAME]-[CDATE]/">[VERSION]</a>
fantasai@5659 41 -->
fantasai@365 42 <dt>Latest version:</dt>
fantasai@365 43 <dd><a
smurakam@2100 44 href="http://www.w3.org/TR/css3-writing-modes/">http://www.w3.org/TR/css3-writing-modes/</a></dd>
fantasai@3400 45 <dt>Latest editor's draft:</dt>
fantasai@3370 46 <dd><a href="http://dev.w3.org/csswg/css3-writing-modes/">http://dev.w3.org/csswg/css3-writing-modes/</a></dd>
fantasai@365 47 <dt>Previous version:</dt>
fantasai@7009 48 <dd><a href="http://www.w3.org/TR/2012/WD-css3-writing-modes-20120501/">http://www.w3.org/TR/2012/WD-css3-writing-modes-20120501/</a></dd>
fantasai@4182 49 <dt>Issues List:</dt>
fantasai@5653 50 <dd><a href="http://www.w3.org/Style/CSS/Tracker/products/30">http://www.w3.org/Style/CSS/Tracker/products/30</a>
fantasai@7857 51 <dt>Feedback:</dt>
dbaron@7921 52 <dd><a href="mailto:www-style@w3.org?subject=%5Bcss-writing-modes%5D%20feedback">www-style@w3.org</a>
fantasai@7857 53 with subject line &ldquo;<kbd>[css-writing-modes <var>&hellip; message topic &hellip;</var></kbd>&rdquo;
fantasai@7857 54 (<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)
fantasai@365 55 <dt>Editors:</dt>
fantasai@3370 56 <dd><a href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a> (Mozilla)</dd>
koji@6313 57 <dd><a href="mailto:koji.a.ishii@mail.rakuten.com">Koji Ishii</a> (Rakuten, Inc.)</dd>
fantasai@3911 58 <dt>Previous Editors:</dt>
kojiishi@2098 59 <dd><a href="mailto:murakami@antenna.co.jp">Shinyu Murakami</a> (<a href="http://www.antenna.co.jp/">Antenna House</a>)</dd>
fantasai@365 60 <dd><a href="mailto:paulnel@microsoft.com">Paul Nelson</a> (<a href="http://www.microsoft.com/">Microsoft</a>)</dd>
fantasai@365 61 <dd><a href="mailto:michelsu@microsoft.com">Michel Suignard</a> (<a href="http://www.microsoft.com/">Microsoft</a>)</dd>
rhauck@8599 62 <dt>Test Suite:</dt>
rhauck@8599 63 <dd><a href="http://test.csswg.org/suites/css3-writing-modes/nightly-unstable/">http://test.csswg.org/suites/css3-writing-modes/nightly-unstable/</a></dd>
fantasai@365 64 </dl>
fantasai@365 65
fantasai@2304 66 <!--copyright-->
fantasai@365 67
fantasai@365 68 <hr title="Separator for header">
fantasai@365 69 </div>
fantasai@365 70
fantasai@2827 71 <h2 class="no-num no-toc" id="abstract">
fantasai@2827 72 Abstract</h2>
fantasai@365 73
fantasai@7019 74 <p>CSS Writing Modes Level 3 defines CSS support for various international
fantasai@2304 75 writing modes, such as left-to-right (e.g. Latin or Indic), right-to-left
fantasai@2304 76 (e.g. Hebrew or Arabic), bidirectional (e.g. mixed Latin and Arabic) and
fantasai@2304 77 vertical (e.g. Asian scripts).</p>
fantasai@1767 78
fantasai@2026 79 <p>Inherently bottom-to-top scripts are not handled in this version. See
fantasai@2026 80 [[UTN22]] for an explanation of relevant issues.</p>
fantasai@2026 81
fantasai@2827 82 <h2 class="no-num no-toc" id="status">
fantasai@2827 83 Status of this document</h2>
fantasai@2198 84
fantasai@2302 85 <!--status-->
fantasai@2198 86
fantasai@3015 87 <p>The following features are at-risk and may be dropped during CR:
fantasai@3015 88 <ul>
fantasai@3015 89 <li>The ''use-glyph-orientation'' of 'text-orientation'
kojiishi@7378 90 <li>The ''digits'' value of 'text-combine-horizontal'.
fantasai@3015 91 </ul>
fantasai@3015 92
fantasai@2827 93 <h2 class="no-num no-toc" id="Contents">
fantasai@2827 94 Table of Contents</h2>
fantasai@2198 95
fantasai@2302 96 <!--toc-->
fantasai@2198 97
fantasai@2827 98 <h2 id="text-flow">
fantasai@2827 99 Introduction to Writing Modes</h2>
fantasai@365 100
fantasai@3398 101 <p>CSS Writing Modes Level 3 defines CSS features to support for various international
fantasai@2304 102 writing modes, such as left-to-right (e.g. Latin or Indic), right-to-left
fantasai@2304 103 (e.g. Hebrew or Arabic), bidirectional (e.g. mixed Latin and Arabic) and
fantasai@2304 104 vertical (e.g. Asian scripts).</p>
fantasai@2304 105
fantasai@2103 106 <p>A <dfn>writing mode</dfn> in CSS is determined by the 'writing-mode',
fantasai@2103 107 'direction', and 'text-orientation' properties. It is defined primarily
fantasai@2120 108 in terms of its <i>inline base direction</i> and <i>block flow
fantasai@2103 109 direction</i>:
fantasai@1992 110
fantasai@2059 111 <div class="sidebar">
fantasai@2059 112 <div class="figure right">
fantasai@2901 113 <a href="diagrams/text-flow-vectors-tb.svg" type="image/svg+xml">
kojiishi@2935 114 <img src="diagrams/text-flow-vectors-tb.png" class="landscape"
kojiishi@2935 115 alt="Latin-based writing mode"></a>
fantasai@2059 116 <p class="caption">Latin-based writing mode
fantasai@2059 117 </div>
fantasai@2901 118 <div class="figure left">
fantasai@2901 119 <a href="diagrams/text-flow-vectors-lr-reverse.svg" type="image/svg+xml">
kojiishi@2935 120 <img src="diagrams/text-flow-vectors-lr-reverse.png" class="landscape"
kojiishi@2935 121 alt="Mongolian-based writing mode"></a>
fantasai@2901 122 <p class="caption">Mongolian-based writing mode
fantasai@2901 123 </div>
fantasai@2901 124 <div class="figure right">
fantasai@2901 125 <a href="diagrams/text-flow-vectors-tb.svg" type="image/svg+xml">
kojiishi@2935 126 <img src="diagrams/text-flow-vectors-tb.png" class="landscape"
kojiishi@2935 127 alt="Han-based writing mode"></a>
fantasai@2901 128 <a href="diagrams/text-flow-vectors-rl.svg" type="image/svg+xml">
kojiishi@2935 129 <img src="diagrams/text-flow-vectors-rl.png" class="landscape"
kojiishi@2935 130 alt="Han-based writing mode"></a>
fantasai@2901 131 <p class="caption">Han-based writing mode
fantasai@2901 132 </div>
fantasai@2059 133 </div>
fantasai@2059 134
fantasai@2120 135 <p>The <dfn>inline base direction</dfn> is the primary direction in which
fantasai@8130 136 content is ordered on a line and defines on which sides the “start”
fantasai@8130 137 and “end” of a line are. The 'direction' property specifies the
fantasai@2120 138 inline base direction of an element and, together with the 'unicode-bidi'
fantasai@2058 139 property and the inherent directionality of any text content, determines
fantasai@1992 140 the ordering of inline-level content within a line.
fantasai@1992 141
fantasai@1992 142 <p>The <dfn>block flow direction</dfn> is the direction in which
fantasai@1992 143 block-level boxes stack and the direction in which line boxes stack
fantasai@1992 144 within a block container. The 'writing-mode' property determines the
fantasai@1992 145 block flow direction.</p>
fantasai@1992 146
fantasai@1774 147 <p>A <dfn>horizontal writing mode</dfn> is one with horizontal lines of
fantasai@1774 148 text, i.e. a downward or upward block flow. A <dfn>vertical writing
fantasai@1774 149 mode</dfn> is one with vertical lines of text, i.e. a leftward or
fantasai@2103 150 rightward block flow.
fantasai@2103 151
fantasai@2103 152 <p class="note">These terms should not be confused with
fantasai@2103 153 <dfn>vertical block flow</dfn> (which is a downward or
fantasai@1774 154 upward block flow) and <dfn>horizontal block flow</dfn> (which is
fantasai@2946 155 leftward or rightward block flow). To avoid confusion, CSS
fantasai@2103 156 specifications avoid this latter set of terms.</p>
fantasai@365 157
fantasai@2058 158 <p>Writing systems typically have one or two native writing modes. Some
fantasai@2058 159 examples are:
fantasai@2058 160 <ul>
fantasai@2058 161 <li>Latin-based systems are typically written using a left-to-right inline
fantasai@2058 162 direction with a downward (top-to-bottom) block flow direction.
fantasai@2058 163 <li>Arabic-based systems are typically written using a right-to-left
fantasai@2058 164 inline direction with a downward (top-to-bottom) block flow direction.
fantasai@2058 165 <li>Mongolian-based systems are typically written using a top-to-bottom
fantasai@2058 166 inline direction with a rightward (left-to-right) block flow direction.
fantasai@2058 167 <li>Han-based systems are commonly written using a left-to-right inline direction
smurakam@2099 168 with a downward (top-to-bottom) block flow direction, <strong>or</strong>
fantasai@2058 169 a top-to-bottom inline direction with a leftward (right-to-left) block
fantasai@2058 170 flow direction. Many magazines and newspapers will mix these two writing
fantasai@2058 171 modes on the same page.
fantasai@2058 172 </ul>
fantasai@2058 173
fantasai@2863 174 <p>The 'text-orientation' component of the writing mode determines the
kojiishi@4699 175 <i>line orientation</i>, and controls
fantasai@2863 176 details of text layout such as the <i>glyph orientation</i>.
fantasai@2863 177
fantasai@2058 178 <p class="note">See Unicode Technical Note #22 [[UTN22]]
fantasai@2026 179 (<a href="http://fantasai.inkedblade.net/style/discuss/vertical-text/paper">HTML version</a>)
fantasai@2058 180 for a more in-depth introduction to writing modes and vertical text.
fantasai@2026 181
fantasai@2827 182 <h3 id="placement">
fantasai@2827 183 Module Interactions</h3>
fantasai@2567 184
fantasai@2567 185 <p>This module replaces and extends the 'unicode-bidi' and 'direction'
smurakam@2968 186 features defined in [[!CSS21]] sections 8.6 and 9.10.
fantasai@2567 187
fantasai@2827 188 <h3 id="values">
fantasai@2827 189 Values</h3>
fantasai@2567 190
fantasai@2567 191 <p>This specification follows the
fantasai@2567 192 <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
fantasai@2567 193 definition conventions</a> from [[!CSS21]]. Value types not defined in
fantasai@2567 194 this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
fantasai@2567 195 Other CSS modules may expand the definitions of these value types: for
fantasai@2567 196 example [[CSS3COLOR]], when combined with this module, expands the
fantasai@2567 197 definition of the &lt;color&gt; value type as used in this specification.</p>
fantasai@2567 198
fantasai@2567 199 <p>In addition to the property-specific values listed in their definitions,
fantasai@2567 200 all properties defined in this specification also accept the
fantasai@2567 201 <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
fantasai@2567 202 keyword as their property value. For readability it has not been repeated
fantasai@2567 203 explicitly.
fantasai@2567 204
fantasai@2567 205
fantasai@6075 206 <h2 id="text-direction"><a name="bidi">
fantasai@6075 207 Inline Direction and Bidirectionality</a></h2>
fantasai@365 208
fantasai@1774 209 <p>While the characters in most scripts are written from left to right,
fantasai@1774 210 certain scripts are written from right to left. In some documents,
fantasai@1774 211 in particular those written with the Arabic or Hebrew script, and in
fantasai@1774 212 some mixed-language contexts, text in a single (visually displayed)
fantasai@1774 213 block may appear with mixed directionality. This phenomenon is called
fantasai@1774 214 <span class="index-def" title="bidirectionality (bidi)"><dfn>bidirectionality</dfn></span>, or
fantasai@365 215 "bidi" for short.</p>
fantasai@365 216
fantasai@2302 217 <div class="figure">
fantasai@3044 218 <p><img src="diagrams/bidi.png"
fantasai@3044 219 alt="An example of bidirectional text is a Latin name in an Arabic
fantasai@3044 220 sentence. The sentence overall is typeset right-to-left, but
fantasai@3044 221 the letters in the Latin word in the middle are typeset
fantasai@3044 222 left-to-right.">
fantasai@2542 223 <p class="caption">Bidirectionality</p>
fantasai@2302 224 </div>
fantasai@2302 225
fantasai@365 226 <p>The Unicode standard (<a href="http://www.unicode.org/reports/tr9/">Unicode Standard Annex #9</a>) defines a complex
fantasai@2058 227 algorithm for determining the proper ordering of bidirectional text. The
fantasai@365 228 algorithm consists of an implicit part based on character properties,
fantasai@365 229 as well as explicit controls for embeddings and overrides. CSS relies
fantasai@3331 230 on this algorithm to achieve proper bidirectional rendering.
fantasai@365 231
fantasai@365 232 <p>User agents that support bidirectional text must apply the Unicode
fantasai@3171 233 bidirectional algorithm to every sequence of inline-level boxes uninterrupted
fantasai@6072 234 by any block boundary or
fantasai@6072 235 &ldquo;<a href="http://www.unicode.org/reports/tr9/#Bidirectional_Character_Types">bidi type B</a>&rdquo;
fantasai@6072 236 <dfn>forced paragraph break</dfn>.
fantasai@6072 237 This sequence forms the <dfn title="bidi paragraph">paragraph</dfn> unit
fantasai@6072 238 in the bidirectional algorithm.
fantasai@6072 239 Additionally, any such sequence forming part or all of the contents of a
fantasai@6072 240 <a href="#bidi-isolate"><i>bidi-isolated</i></a> inline element also forms a <i>bidi paragraph</i>.
fantasai@6067 241
fantasai@6067 242 <p>Two CSS properties, 'direction' and 'unicode-bidi',
fantasai@6334 243 provide explicit embedding, isolation, and override controls in the CSS layer.
fantasai@6072 244 Because the base directionality of a text depends on the structure and
fantasai@6067 245 semantics of the document, the 'direction' and 'unicode-bidi' properties
fantasai@6067 246 should in most cases be used only to map bidi information in the markup
fantasai@6067 247 to its corresponding CSS styles.
fantasai@6067 248 <strong>If a document language provides markup features to control
fantasai@6067 249 bidi, authors and users should use those features instead</strong> and not
fantasai@6067 250 specify CSS rules to override them.</p>
fantasai@6067 251
fantasai@6072 252 <p>In general, the paragraph embedding level is set according to
fantasai@6334 253 the 'direction' property of the paragraph's containing block
fantasai@6072 254 rather than by the heuristic given in steps P2 and P3 of the Unicode algorithm. [[!UAX9]]
fantasai@6334 255 When the computed 'unicode-bidi' of the paragraph's containing block is ''plaintext'',
fantasai@6334 256 however, the Unicode heuristics (rules P2 and P3) are used instead.
fantasai@365 257
fantasai@6067 258 <p>The HTML specifications ([[HTML401]], section 8.2, and [[HTML5]], section 10.3.5) define
fantasai@6334 259 bidirectionality behavior for HTML elements.</p>
fantasai@365 260
fantasai@365 261 <p class="note">Because HTML UAs can turn off CSS styling, we advise HTML
fantasai@1969 262 authors to use the HTML 'dir' attribute and &lt;bdo&gt; element to
fantasai@365 263 ensure correct bidirectional layout in the absence of a style sheet.</p>
fantasai@365 264
fantasai@2827 265 <h3 id="direction">
fantasai@2827 266 Specifying Directionality: the 'direction' property</h3>
fantasai@365 267
fantasai@365 268 <table class="propdef">
fantasai@365 269 <tbody>
fantasai@365 270 <tr>
fantasai@365 271 <th>Name:</th>
fantasai@365 272 <td><dfn>direction</dfn></td>
fantasai@365 273 </tr>
fantasai@365 274 <tr>
fantasai@5315 275 <th><a href="#values">Value</a>:</th>
fantasai@365 276 <td>ltr | rtl </td>
fantasai@365 277 </tr>
fantasai@365 278 <tr>
fantasai@365 279 <th>Initial:</th>
fantasai@365 280 <td>ltr</td>
fantasai@365 281 </tr>
fantasai@365 282 <tr>
fantasai@365 283 <th>Applies to:</th>
fantasai@365 284 <td>all elements</td>
fantasai@365 285 </tr>
fantasai@365 286 <tr>
fantasai@365 287 <th>Inherited:</th>
fantasai@365 288 <td>yes</td>
fantasai@365 289 </tr>
fantasai@365 290 <tr>
fantasai@365 291 <th>Percentages:</th>
fantasai@365 292 <td>N/A</td>
fantasai@365 293 </tr>
fantasai@365 294 <tr>
fantasai@365 295 <th>Media:</th>
fantasai@365 296 <td>visual</td>
fantasai@365 297 </tr>
fantasai@365 298 <tr>
fantasai@365 299 <th>Computed&#160;value:</th>
fantasai@365 300 <td>specified value</td>
fantasai@365 301 </tr>
fantasai@365 302 </tbody>
fantasai@365 303 </table>
fantasai@365 304
fantasai@5635 305 <p>This property specifies the inline base direction or directionality
fantasai@6334 306 of any bidi paragraph, embedding, isolate, or override established by the element.
fantasai@6334 307 (See 'unicode-bidi'.) <!-- except plaintext -->
fantasai@5635 308 In addition, it informs the ordering of
fantasai@5635 309 <a href="http://www.w3.org/TR/CSS21/tables.html">table</a> column layout,
fantasai@1969 310 the direction of horizontal <a href="http://www.w3.org/TR/CSS21/visufx.html#overflow">overflow</a>,
fantasai@5635 311 and the default alignment of text within a line, and other layout effects
fantasai@5635 312 that depend on the element's inline base direction.</p>
fantasai@365 313
fantasai@365 314 <p>Values for this property have the following meanings:</p>
fantasai@365 315
fantasai@365 316 <dl>
fantasai@2732 317 <dt><dfn>ltr</dfn></dt>
fantasai@1969 318 <dd>Left-to-right directionality.</dd>
fantasai@2732 319 <dt><dfn>rtl</dfn></dt>
fantasai@2067 320 <dd>Right-to-left directionality.</dd>
fantasai@365 321 </dl>
fantasai@365 322
fantasai@2543 323 <p class="note">The 'direction' property has no effect on bidi reordering
fantasai@2543 324 when specified on inline elements whose 'unicode-bidi' property's
kojiishi@6954 325 value is ''normal'', because the element does not open an additional level
kojiishi@6954 326 of embedding with respect to the bidirectional algorithm.</p>
fantasai@2120 327
fantasai@2067 328 <p>The value of the 'direction' property on the root element is also
fantasai@2067 329 propagated to the initial containing block and, together with the
fantasai@2067 330 'writing-mode' property, determines the document's principal writing
fantasai@2067 331 mode. (See <a href="#principal-writing-mode">below</a>.)
fantasai@2067 332
fantasai@2120 333 <p class="note">Note that the 'direction' property of the HTML BODY
fantasai@2120 334 element is <em>not</em> propagated to the viewport. That special
fantasai@2120 335 behavior only applies to the background and overflow properties.
fantasai@365 336
fantasai@1969 337 <p class="note">The 'direction'
fantasai@1969 338 property, when specified for table column elements, is not inherited by
fantasai@1969 339 cells in the column since columns are not the ancestors of the cells in
fantasai@365 340 the document tree. Thus, CSS cannot easily capture the "dir" attribute
bert@1769 341 inheritance rules described in [[HTML401]], section 11.3.2.1.
fantasai@365 342
fantasai@2827 343 <h3 id="unicode-bidi">
fantasai@2827 344 Embeddings and Overrides: the 'unicode-bidi' property</h3>
fantasai@365 345
fantasai@365 346 <table class="propdef">
fantasai@365 347 <tbody>
fantasai@365 348 <tr>
fantasai@365 349 <th>Name:</th>
fantasai@365 350 <td><dfn>unicode-bidi</dfn></td>
fantasai@365 351 </tr>
fantasai@365 352 <tr>
fantasai@5315 353 <th><a href="#values">Value</a>:</th>
fantasai@6050 354 <td>normal | embed | isolate | bidi-override | isolate-override | plaintext
fantasai@365 355 </tr>
fantasai@365 356 <tr>
fantasai@365 357 <th>Initial:</th>
fantasai@365 358 <td>normal</td>
fantasai@365 359 </tr>
fantasai@365 360 <tr>
fantasai@365 361 <th>Applies to:</th>
fantasai@365 362 <td>all elements, but see prose</td>
fantasai@365 363 </tr>
fantasai@365 364 <tr>
fantasai@365 365 <th>Inherited:</th>
fantasai@365 366 <td>no</td>
fantasai@365 367 </tr>
fantasai@365 368 <tr>
fantasai@365 369 <th>Percentages:</th>
fantasai@365 370 <td>N/A</td>
fantasai@365 371 </tr>
fantasai@365 372 <tr>
fantasai@365 373 <th>Media:</th>
fantasai@365 374 <td>visual</td>
fantasai@365 375 </tr>
fantasai@365 376 <tr>
fantasai@365 377 <th>Computed&#160;value:</th>
fantasai@365 378 <td>specified value</td>
fantasai@365 379 </tr>
fantasai@365 380 </tbody>
fantasai@365 381 </table>
fantasai@365 382
fantasai@6050 383 <p>Normally (i.e. when 'unicode-bidi' is ''normal'')
fantasai@6050 384 an inline element is transparent to the unicode bidi algorithm;
fantasai@6334 385 content is ordered as if the element's boundaries were not there.
fantasai@6334 386 Other values of the 'unicode-bidi' property cause inline elements
fantasai@6334 387 to create scopes within the algorithm,
fantasai@6050 388 and to override the intrinsic directionality of text.
fantasai@6050 389
fantasai@6050 390 <p>The following informative table summarizes the element-internal and
fantasai@6050 391 element-external effects of 'unicode-bidi':
fantasai@6050 392
fantasai@6050 393 <table class="data">
fantasai@6050 394 <caption>Effect of non-''normal'' values of 'unicode-bidi' on inline elements</caption>
fantasai@6050 395 <colgroup span=2></colgroup>
fantasai@6050 396 <colgroup span=3></colgroup>
fantasai@6050 397 <thead>
fantasai@6050 398 <tr><th colspan=2 rowspan=2>
fantasai@6050 399 <th colspan=3 scope=rowgroup><abbr title="To surrounding contents, the element behaves as if its boundary were...">Outside</abbr>
fantasai@6050 400 <tr><th><abbr title="a strong character of the element's 'direction'.">strong</abbr>
fantasai@6050 401 <th><abbr title="a neutral character.">neutral</abbr>
fantasai@6050 402 </thead>
fantasai@6050 403 <tbody>
fantasai@6050 404 <tr><th rowspan=3 scope=colgroup><abbr title="Within the element, content is ordered as if...">Inside</abbr>
fantasai@6072 405 <th><abbr title="the element's boundaries were strong characters of the element's 'direction'.">scoped</abbr>
fantasai@6050 406 <td>''embed''
fantasai@6050 407 <td>''isolate''
fantasai@6050 408 <tr><th><abbr title="all text consisted of strong characters of the element's 'direction'.">override</abbr>
fantasai@6050 409 <td>''bidi-override''
fantasai@6050 410 <td>''isolate-override''
fantasai@6050 411 <tr><th><abbr title="the element were a standalone paragraph ordered using UAX9 heuristics.">plaintext</a>
fantasai@6050 412 <td>&mdash;
fantasai@6050 413 <td>''plaintext''
fantasai@6050 414 </tbody>
fantasai@6050 415 </table>
fantasai@6050 416
fantasai@6050 417 <p>Values for this property have the following (normative) meanings:</p>
fantasai@365 418
fantasai@365 419 <dl>
fantasai@2732 420 <dt><dfn>normal</dfn></dt>
fantasai@365 421 <dd>The element does not open an additional level of embedding with
fantasai@2567 422 respect to the bidirectional algorithm. For inline elements,
fantasai@365 423 implicit reordering works across element boundaries.</dd>
fantasai@2732 424 <dt><dfn>embed</dfn></dt>
fantasai@6334 425 <dd>If the element is inline, this value creates a <dfn>directional embedding</dfn>
fantasai@6334 426 by opening an additional level of embedding with respect to the bidirectional algorithm.
fantasai@2567 427 The direction of this embedding level is given by the 'direction'
fantasai@365 428 property. Inside the element, reordering is done implicitly. This
fantasai@2567 429 corresponds to adding a LRE (U+202A), for 'direction: ltr', or RLE
fantasai@2567 430 (U+202B), for 'direction: rtl', at the start of the element and a PDF
fantasai@2567 431 (U+202C) at the end of the element.
fantasai@2567 432 <span class="note">This value has no effect on elements that are
fantasai@2567 433 not inline.</span></dd>
fantasai@2732 434 <dt><dfn>isolate</dfn></dt>
fantasai@6334 435 <dd>On an inline element, this <dfn id=bidi-isolate title="bidi-isolate|bidi isolation|isolation">bidi-isolates</dfn> its contents.
fantasai@6334 436 This is similar to a directional embedding (and increases the embedding level accordingly)
fantasai@6334 437 except that each sequence of inline-level boxes
fantasai@6334 438 uninterrupted by any block boundary or <i>forced paragraph break</i>
fantasai@6334 439 is treated as an <dfn>isolated sequence<dfn>:
fantasai@6334 440 <ul>
fantasai@6334 441 <li>the content within the sequence is ordered
fantasai@6334 442 as if inside an independent paragraph
fantasai@6334 443 with the base directionality specified by the element's 'direction' property.
fantasai@6334 444 <li>for the purpose of bidi resolution in its containing bidi paragraph,
fantasai@6334 445 the sequence is treated as if it were a single Object Replacement Character (U+FFFC).
fantasai@6334 446 </ul>
fantasai@6334 447 In effect, neither is the content inside the element bidi-affected
fantasai@6334 448 by the content surrounding the element,
fantasai@6334 449 nor is the content surrounding the element bidi-affected by the
fantasai@6334 450 content or specified directionality of the element.
fantasai@6334 451 However, <i>forced paragraph breaks</i> within the element still create
fantasai@6334 452 a corresponding break in the containing paragraph.
fantasai@7056 453 <p class="note">In Unicode 6.3 and beyond,
fantasai@6334 454 this will correspond to adding an LRI (U+2066), for ''direction: ltr'',
fantasai@6334 455 or RLI (U+2067), for ''direction: rtl'', at the start of the element,
fantasai@6334 456 and a PDI (U+2069) at the end of the element.
fantasai@6334 457 <p class="note">This value has no effect on elements that are not inline.</span>
fantasai@2732 458 <dt><dfn>bidi-override</dfn></dt>
fantasai@6334 459 <dd>This value puts the element's immediate content in a <dfn>directional override</dfn>.
fantasai@6334 460 For an inline, this means that the element acts like a <i>directional embedding</i>
fantasai@6334 461 in the bidirectional algorithm,
fantasai@6334 462 except that reordering within it is strictly in sequence according to the
fantasai@2567 463 'direction' property; the implicit part of the bidirectional algorithm
fantasai@2567 464 is ignored. This corresponds to adding a LRO (U+202D), for ''direction:
fantasai@2567 465 ltr'', or RLO (U+202E), for ''direction: rtl'', at the start of the
fantasai@6334 466 element and a PDF (U+202C) at the end of the element.
fantasai@6334 467 If the element is a block container,
fantasai@6334 468 the override is applied to an anonymous inline element
fantasai@6334 469 that surrounds all of its content.</dd>
fantasai@6050 470 <dt><dfn>isolate-override<dfn></dt>
fantasai@6072 471 <dd>This combines the <i>isolation</i> behavior of ''isolate'' with the
fantasai@6072 472 <i>override</i> behavior of ''bidi-override'': to surrounding content,
fantasai@6050 473 it is equivalent to ''isolate'', but within the element content
fantasai@6050 474 is ordered as if ''bidi-override'' were specified.
fantasai@2957 475 <dt><dfn>plaintext</dfn></dt>
fantasai@5215 476 <dd><p>This value behaves as ''isolate'' except that for the purposes of
fantasai@5215 477 the Unicode bidirectional algorithm, the base directionality of each
fantasai@6334 478 of the element's <i>bidi paragraphs</i> (if a block container)
fantasai@6334 479 or <i>isolated sequences</i> (if an inline)
fantasai@6334 480 is determined by following the heuristic in rules P2 and P3
fantasai@6334 481 of the Unicode bidirectional algorithm
fantasai@6072 482 (rather than by using the 'direction' property of the element).
fantasai@7056 483 <p class="note">In Unicode 6.3 and beyond, for inline elements
fantasai@6334 484 this will correspond to adding an FSI (U+2068) at the start of the element,
fantasai@6334 485 and a PDI (U+2069) at the end of the element.
fantasai@365 486 </dl>
fantasai@365 487
fantasai@5212 488 <p class=note>Because the 'unicode-bidi' property does not inherit,
fantasai@5212 489 setting ''bidi-override'' or ''plaintext'' on a block element will
fantasai@5212 490 not affect any descendant blocks. Therefore these values are best
fantasai@5212 491 used on blocks and inlines that do not contain any block-level
fantasai@5212 492 structures.
fantasai@5212 493
fantasai@5215 494 <p class=note>Note that 'unicode-bidi' does not affect the 'direction'
fantasai@5215 495 property even in the case of ''plaintext'', and thus does not affect
fantasai@5653 496 'direction'-dependent layout calculations.
fantasai@5215 497
fantasai@6311 498 <p>The final order of characters within each <i>bidi paragraph</i> is the
fantasai@365 499 same as if the bidi control codes had been added as described above,
fantasai@365 500 markup had been stripped, and the resulting character sequence had
fantasai@365 501 been passed to an implementation of the Unicode bidirectional
fantasai@365 502 algorithm for plain text that produced the same line-breaks as the
fantasai@2773 503 styled text.
fantasai@2456 504
fantasai@6072 505 <p>In this process, replaced elements with ''display: inline''
fantasai@6072 506 are treated as neutral characters,
fantasai@6072 507 unless their 'unicode-bidi' property is either 'embed' or 'bidi-override',
fantasai@6072 508 in which case they are treated as strong characters
fantasai@6072 509 in the 'direction' specified for the element.
fantasai@2456 510 All other atomic inline-level boxes are treated as neutral characters
fantasai@2456 511 always.</p>
fantasai@365 512
fantasai@6072 513 <p>If an inline element is broken around a <i>bidi paragraph</i>
fantasai@6072 514 boundary (e.g. if split by a block or <i>forced paragraph break</i>), then
fantasai@6334 515 the bidi control codes assigned to the end of the element
fantasai@6334 516 are added before the interruption and the codes assigned to the
fantasai@2773 517 start of the element are added after it. (In other words, any embedding
fantasai@2773 518 levels or overrides started by the element are closed at the paragraph
fantasai@2773 519 break and reopened on the other side of it.)
fantasai@2773 520
fantasai@6334 521 <div class="example">
fantasai@6334 522 <p>For example, where &lt;BR/&gt; is a <i>forced paragraph break</i>
fantasai@6334 523 the bidi ordering is identical between
fantasai@6334 524 <pre>&lt;para>...&lt;i1>&lt;i2>...&lt;BR/>...&lt;/i2>&lt;i1>...&lt;/para></pre>
fantasai@6334 525 <p>and
fantasai@6334 526 <pre>&lt;para>...&lt;i1>&lt;i2>...&lt;/i2>&lt;i1>&lt;BR/>&lt;i1>&lt;i2>...&lt;/i2>&lt;i1>...&lt;/para></pre>
fantasai@6334 527 <p>for all values of 'unicode-bidi' on inline elements &lt;i1&gt; and &lt;i2&gt;.
fantasai@6334 528 </div>
fantasai@6334 529
fantasai@6334 530 <p class="note">
fantasai@6334 531 Because the Unicode algorithm has a limit of 61 levels of embedding,
fantasai@6072 532 care should be taken not to use 'unicode-bidi'
fantasai@6072 533 with a value other than 'normal' unless appropriate.
fantasai@6072 534 In particular, a value of ''inherit''
fantasai@365 535 should be used with extreme caution. However, for elements that are,
fantasai@365 536 in general, intended to be displayed as blocks, a setting of
fantasai@6072 537 ''unicode-bidi: isolate'' is preferred to keep the element together
fantasai@6072 538 in case the 'display' is changed to ''inline''
fantasai@6072 539 (see example below).</p>
fantasai@365 540
fantasai@2827 541 <h3 id="bidi-example">
fantasai@2827 542 Example of Bidirectional Text</h3>
fantasai@2773 543
fantasai@7057 544 <p>The following example shows an SGML document with bidirectional
fantasai@1969 545 text. It illustrates an important design principle: document language
fantasai@1969 546 designers should take bidi into account both in the language proper
fantasai@1969 547 (elements and attributes) and in any accompanying style sheets. The
fantasai@1969 548 style sheets should be designed so that bidi rules are separate from
fantasai@1969 549 other style rules, and such rules should not be overridden by other
fantasai@1969 550 style sheets so that the document language's bidi behavior is preserved.</p>
fantasai@365 551
fantasai@365 552 <div class="example">
fantasai@365 553 <p>In this example, lowercase letters stand for inherently left-to-right
fantasai@365 554 characters and uppercase letters represent inherently right-to-left
fantasai@365 555 characters. The text stream is shown in logical backing store order.</p>
fantasai@365 556
fantasai@365 557 <pre class="xml-example"><code class="xml">
fantasai@7057 558 &lt;section dir=rtl&gt;
fantasai@7057 559 &lt;para&gt;HEBREW1 HEBREW2 english3 HEBREW4 HEBREW5&lt;/para&gt;
fantasai@7057 560 &lt;para&gt;HEBREW6 &lt;emphasis&gt;HEBREW7&lt;/emphasis&gt; HEBREW8&lt;/para&gt;
fantasai@7057 561 &lt;/section&gt;
fantasai@7057 562 &lt;section dir=ltr&gt;
fantasai@7057 563 &lt;para&gt;english9 english10 english11 HEBREW12 HEBREW13&lt;/para&gt;
fantasai@7057 564 &lt;para&gt;english14 english15 english16&lt;/para&gt;
fantasai@7057 565 &lt;para&gt;english17 &lt;quote dir=rtl&gt;HEBREW18 english19 HEBREW20&lt;/quote&gt;&lt;/para&gt;
fantasai@7057 566 &lt;/section&gt;
fantasai@365 567 </code></pre>
fantasai@365 568
fantasai@7057 569 <p>Since this is arbitrary SGML, the style sheet is responsible for
fantasai@1969 570 setting the writing direction. This is the style sheet:</p>
fantasai@365 571
fantasai@1969 572 <pre>
fantasai@365 573 /* Rules for bidi */
fantasai@7057 574 [dir=ltr] {direction: rtl;}
fantasai@7057 575 [dir=rtl] {direction: ltr;}
fantasai@7057 576 quote {unicode-bidi: isolate;}
fantasai@365 577
fantasai@365 578 /* Rules for presentation */
fantasai@7057 579 section, para {display: block;}
fantasai@7057 580 emphasis {font-weight: bold;}
fantasai@365 581 </pre>
fantasai@365 582
fantasai@7057 583 <p>The first <code>&lt;section></code> element is a block with a right-to-left base direction,
fantasai@7057 584 the second <code>&lt;section></code> element is a block with a left-to-right base direction.
fantasai@7057 585 The <code>&lt;para></code>s are blocks that inherit the base direction from their parents.
fantasai@7057 586 Thus, the first two <code>&lt;para></code>s are read starting at the top right,
fantasai@7057 587 the final three are read starting at the top left.</p>
fantasai@7057 588
fantasai@7057 589 <p>The <code>&lt;emphasis></code> element is inline-level,
fantasai@7057 590 and since its value for 'unicode-bidi' is ''normal'' (the initial value),
fantasai@7057 591 it has no effect on the ordering of the text.
fantasai@7057 592 The <code>&lt;quote></code> element, on the other hand,
fantasai@7057 593 creates an <i>isolated sequence</i> with the given internal directionality.
fantasai@365 594
fantasai@365 595 <p>The formatting of this text might look like this if the line length
fantasai@365 596 is long:</p>
fantasai@365 597
fantasai@365 598 <pre class="ascii-art">
fantasai@365 599 5WERBEH 4WERBEH english3 2WERBEH 1WERBEH
fantasai@365 600
fantasai@365 601 8WERBEH <b>7WERBEH</b> 6WERBEH
fantasai@365 602
fantasai@365 603 english9 english10 english11 13WERBEH 12WERBEH
fantasai@365 604
fantasai@365 605 english14 english15 english16
fantasai@365 606
fantasai@365 607 english17 20WERBEH english19 18WERBEH
fantasai@365 608 </pre>
fantasai@365 609
fantasai@7057 610 <p>Note that the <code>&lt;quote></code> embedding causes
fantasai@7057 611 <samp>HEBREW18</samp> to be to the right of <samp>english19</samp>.
fantasai@365 612
fantasai@365 613 <p>If lines have to be broken, it might be more like this:</p>
fantasai@365 614
fantasai@365 615 <pre class="ascii-art">
fantasai@365 616 2WERBEH 1WERBEH
fantasai@365 617 -EH 4WERBEH english3
fantasai@365 618 5WERB
fantasai@365 619
fantasai@365 620 -EH <b>7WERBEH</b> 6WERBEH
fantasai@365 621 8WERB
fantasai@365 622
fantasai@365 623 english9 english10 en-
fantasai@365 624 glish11 12WERBEH
fantasai@365 625 13WERBEH
fantasai@365 626
fantasai@365 627 english14 english15
fantasai@365 628 english16
fantasai@365 629
fantasai@365 630 english17 18WERBEH
fantasai@365 631 20WERBEH english19
fantasai@365 632 </pre>
fantasai@365 633
fantasai@7057 634 <p>Because <samp>HEBREW18</samp> must be read before english19,
fantasai@7057 635 it is on the line above <samp>english19</samp>.
fantasai@7057 636 Just breaking the long line from the earlier formatting would not have worked.
fantasai@7057 637 Note also that the first syllable from <samp>english19</samp>
fantasai@7057 638 might have fit on the previous line,
fantasai@7057 639 but hyphenation of left-to-right words in a right-to-left context, and vice versa,
fantasai@7057 640 is usually suppressed to avoid having to display a hyphen in the middle of a line.
fantasai@365 641
fantasai@365 642 </div><!-- example -->
fantasai@365 643
fantasai@2827 644 <h3 id="bidi-box-model">
fantasai@2827 645 Box model for inline elements in bidirectional context</h3>
fantasai@2775 646
fantasai@2775 647 <p>Since bidi reordering can split apart and reorder text that is
fantasai@6311 648 logically contiguous, bidirectional text can cause an inline box
fantasai@2775 649 to be split and reordered within a line.
fantasai@2775 650
fantasai@2775 651 <p class="note">Note that in order to be able to flow inline boxes in a
fantasai@2775 652 uniform direction (either entirely left-to-right or entirely
fantasai@2775 653 right-to-left), anonymous inline boxes may have to be created.</p>
fantasai@2775 654
fantasai@1969 655 <!-- CSS2.1 8.6 -->
fantasai@1969 656 <p>For each line box, UAs must take the inline boxes generated for each
fantasai@1969 657 element and render the margins, borders and padding in visual order
fantasai@2775 658 (not logical order). The <i>start</i>-most box on the first line box
fantasai@2775 659 in which the element appears has the <i>start</i> edge's margin, border,
fantasai@2775 660 and padding; and the end-most box on the last line box in which the
fantasai@2775 661 element appears has the <i>end</i> edge's margin, border, and padding.
fantasai@2775 662 For example, in the ''horizontal-tb'' writing mode:
fantasai@2775 663 <ul>
smurakam@2968 664 <li>When the parent's 'direction' property is ''ltr'', the left-most
fantasai@2775 665 generated box of the first line box in which the element appears
fantasai@2775 666 has the left margin, left border and left padding, and the right-most
fantasai@2775 667 generated box of the last line box in which the element appears has
fantasai@2775 668 the right padding, right border and right margin.
fantasai@2956 669 <li>When the parent's 'direction' property is ''rtl'', the right-most
fantasai@2775 670 generated box of the first line box in which the element appears has
fantasai@2775 671 the right padding, right border and right margin, and the left-most
fantasai@2775 672 generated box of the last line box in which the element appears has
fantasai@2775 673 the left margin, left border and left padding.
fantasai@2775 674 </ul>
fantasai@2775 675 <p>Analogous rules hold for vertical writing modes.</p>
fantasai@1969 676
fantasai@2775 677 <p class="note">The 'box-decoration-break' property can override this
kojiishi@2935 678 behavior to draw box decorations on both sides of each box. [[!CSS3BG]] </p>
fantasai@365 679
fantasai@2304 680 <h2 id="vertical-intro">
fantasai@2304 681 Introduction to Vertical Text</h2>
fantasai@2302 682
fantasai@2946 683 <p><em>This subsection is non-normative.</em></p>
fantasai@2946 684
fantasai@2775 685 <p>In addition to extensions to CSS2.1&rsquo;s support for bidirectional text,
fantasai@2302 686 this module introduces the rules and properties needed to support vertical
fantasai@2302 687 text layout in CSS.
fantasai@2302 688
fantasai@2302 689 <p>Unlike languages that use the Latin script which are primarily laid out
fantasai@2478 690 horizontally, Asian languages such as Chinese and Japanese can be laid out
fantasai@2302 691 vertically. The Japanese example below shows the same text laid out
fantasai@2302 692 horizontally and vertically. In the horizontal case, text is read
fantasai@2302 693 from left to right, top to bottom. For the vertical case, the text is
fantasai@2302 694 read top to bottom, right to left.
fantasai@2302 695 Indentation from the left edge in the left-to-right horizontal case
fantasai@2302 696 translates to indentation from the top edge in the top-to-bottom vertical
fantasai@2302 697 case.
fantasai@2302 698
fantasai@2302 699 <div class="figure">
fantasai@2302 700 <p><img src="vert-horiz-comparison.png"
fantasai@2302 701 alt="A comparison of horizontal and vertical Japanese shows that
fantasai@2302 702 although the lines rotate, the characters remain upright.
fantasai@2302 703 Some glyphs, however change: a period mark shifts from the
fantasai@2302 704 bottom left of its glyph box to the top right. Running
fantasai@2302 705 headers, however, may remain
fantasai@2415 706 laid out horizontally across the top of the page."></p>
kojiishi@2352 707 <p class="caption">Comparison of vertical and horizontal Japanese: iBunko application (iOS)</p>
fantasai@2302 708 </div>
fantasai@2302 709
fantasai@2302 710 <p class="note">For Chinese and Japanese lines are ordered either right
fantasai@2777 711 to left or top to bottom, while for Mongolian and Manchu lines are
fantasai@2777 712 ordered left to right.</p>
fantasai@2302 713
fantasai@2302 714 <p>The change from horizontal to vertical writing can affect not just the
fantasai@2302 715 layout, but also the typesetting. For example, the position of a punctuation
fantasai@2302 716 mark within its spacing box can change from the horizontal to the
fantasai@2302 717 vertical case, and in some cases alternate glyphs are used.
fantasai@2302 718
fantasai@2302 719 <p>Vertical text that includes Latin script text or text from other scripts
fantasai@2302 720 normally displayed horizontally can display that text in a number of
fantasai@2302 721 ways. For example, Latin words can be rotated sideways, or each letter
kojiishi@2352 722 can be oriented upright:
fantasai@2302 723
fantasai@2302 724 <div class="figure">
fantasai@2302 725 <p><img src="vert-latin-layouts.png"
kojiishi@2352 726 alt="A dictionary definition for &#x30F4;&#x30A3;&#x30EB;&#x30B9;
kojiishi@2352 727 might write the English word 'virus' rotated 90&deg; clockwise,
fantasai@2415 728 but stack the letters of the initialisms 'RNA' and 'DNA' upright."></p>
kojiishi@2352 729 <p class="caption">Examples of Latin in vertical Japanese: Daijirin Viewer 1.4 (iOS)</</p>
fantasai@2302 730 </div>
fantasai@2302 731
fantasai@2302 732 <p>In some special cases such as two-digit numbers in dates, text is fit
fantasai@2302 733 compactly into a single vertical character box:
fantasai@2302 734
kojiishi@3149 735 <div class="figure" id="fig-mac">
fantasai@2302 736 <p><img src="vert-number-layouts.png"
kojiishi@2622 737 alt="An excerpt from MacFan shows several possible vertical layouts
fantasai@2302 738 for numbers: the two-digit month and day are written as
fantasai@2302 739 horizontal-in-vertical blocks; the years are written with
fantasai@2302 740 each character upright; except in the English phrase
fantasai@2302 741 &ldquo;for Mac 2011&rdquo;, where the date is rotated to
fantasai@2415 742 match the rotated Latin."></p>
kojiishi@2352 743 <p class="caption">Mac Fan, December 2010, p.49</p>
fantasai@2302 744 </div>
fantasai@2302 745
fantasai@2302 746 <p>Layouts often involve a mixture of vertical and horizontal elements:
fantasai@2302 747
fantasai@2302 748 <div class="figure">
fantasai@2302 749 <p><img src="vert-horiz-combination.png"
fantasai@2302 750 alt="Magazines often mix horizontal and vertical layout; for
fantasai@2302 751 example, using one orientation for the main article text
fantasai@2415 752 and a different one for sidebar or illustrative content."></p>
fantasai@2302 753 <p class="caption">Mixture of vertical and horizontal elements</p>
fantasai@2302 754 </div>
fantasai@2302 755
fantasai@2302 756 <p>Vertical text layouts also need to handle bidirectional text layout;
fantasai@2302 757 clockwise-rotated Arabic, for example, is laid out bottom-to-top.
fantasai@2302 758
fantasai@2302 759
fantasai@2306 760 <h3 id="writing-mode">
fantasai@2306 761 Block Flow Direction: the 'writing-mode' property</h3>
fantasai@365 762
fantasai@365 763 <table class="propdef">
fantasai@365 764 <tbody>
fantasai@365 765 <tr>
fantasai@365 766 <th>Name:</th>
fantasai@1974 767 <td><dfn>writing-mode</dfn></td>
fantasai@365 768 </tr>
fantasai@365 769 <tr>
fantasai@5315 770 <th><a href="#values">Value</a>:</th>
fantasai@2173 771 <td>horizontal-tb | vertical-rl | vertical-lr</td>
fantasai@365 772 </tr>
fantasai@365 773 <tr>
fantasai@365 774 <th>Initial:</th>
fantasai@1974 775 <td>horizontal-tb</td>
fantasai@365 776 </tr>
fantasai@365 777 <tr>
fantasai@365 778 <th>Applies to:</th>
fantasai@1974 779 <td>All elements except table row groups, table column groups, table rows, and table columns</td>
fantasai@365 780 </tr>
fantasai@365 781 <tr>
fantasai@365 782 <th>Inherited:</th>
fantasai@365 783 <td>yes</td>
fantasai@365 784 </tr>
fantasai@365 785 <tr>
fantasai@365 786 <th>Percentages:</th>
fantasai@365 787 <td>N/A</td>
fantasai@365 788 </tr>
fantasai@365 789 <tr>
fantasai@365 790 <th>Media:</th>
fantasai@365 791 <td>visual</td>
fantasai@365 792 </tr>
fantasai@365 793 <tr>
fantasai@365 794 <th>Computed&#160;value:</th>
fantasai@365 795 <td>specified value</td>
fantasai@365 796 </tr>
fantasai@365 797 </tbody>
fantasai@365 798 </table>
fantasai@365 799
fantasai@3639 800 <p>This property specifies whether lines of text are laid out horizontally
fantasai@3639 801 or vertically and the direction in which blocks progress. Possible
fantasai@3639 802 values:</p>
fantasai@365 803
fantasai@365 804 <dl>
fantasai@2732 805 <dt><dfn>horizontal-tb</dfn></dt>
fantasai@3639 806 <dd>Top-to-bottom <i>block flow direction</i>.
fantasai@3639 807 The <i>writing mode</i> is horizontal.</dd>
fantasai@2732 808 <dt><dfn>vertical-rl</dfn></dt>
fantasai@3639 809 <dd>Right-to-left <i>block flow direction</i>.
fantasai@3639 810 The <i>writing mode</i> is vertical.</dd>
fantasai@2732 811 <dt><dfn>vertical-lr</dfn></dt>
fantasai@3639 812 <dd>Left-to-right <i>block flow direction</i>.
fantasai@3639 813 The <i>writing mode</i> is vertical.</dd>
fantasai@365 814 </dl>
fantasai@365 815
fantasai@3639 816 <p>The 'writing-mode' property specifies the <i>block flow direction</i>,
fantasai@3639 817 which determines the progression of block-level boxes in a block formatting
fantasai@2067 818 context; the progression of line boxes in a block container that contains
fantasai@3639 819 inlines; the progression of rows in a table; etc. By virtue of determining
fantasai@2304 820 the stacking direction of line boxes, the 'writing-mode' property also
fantasai@3639 821 determines whether the line boxes' orientation (and thus the <i>writing mode</i>)
fantasai@3639 822 is horizontal or vertical. The 'text-orientation' property then determines
fantasai@3639 823 how text is laid out within the line box.
fantasai@3639 824
fantasai@3639 825 <p>The <dfn id="principal-writing-mode">principal writing mode</dfn> of the
fantasai@3639 826 document is determined by the 'writing-mode' and 'direction' values
fantasai@3639 827 specified on the root element. This writing mode is used, for example,
fantasai@2304 828 to determine the default page progression direction. (See [[CSS3PAGE]].)
fantasai@3639 829 Like 'direction', the 'writing-mode' value of the root element is also
fantasai@3639 830 propagated to the initial containing block and sets the block flow
fantasai@3639 831 direction of the initial block formatting context.
fantasai@1973 832
fantasai@2304 833 <p class="note">Note that the 'writing-mode' property of the HTML BODY
fantasai@2120 834 element is <em>not</em> propagated to the viewport. That special
fantasai@2120 835 behavior only applies to the background and overflow properties.
fantasai@2120 836
fantasai@2067 837 <p>If an element has a different block flow direction than its containing
fantasai@2067 838 block:
fantasai@2067 839 <ul>
fantasai@2067 840 <li>If the element has a specified 'display' of ''inline'', its 'display'
fantasai@2067 841 computes to 'inline-block'. [[!CSS21]]
fantasai@2067 842 <li>If the element has a specified 'display' of ''run-in'', its 'display'
fantasai@2067 843 computes to 'block'. [[!CSS21]]
fantasai@3639 844 <li>If the element is a block container, then it establishes a new block
fantasai@3639 845 formatting context.
smurakam@2099 846 </ul>
fantasai@1994 847
fantasai@2103 848 <p>The content of replaced elements do not rotate due to the writing mode:
fantasai@2103 849 images, for example, remain upright. However replaced content
fantasai@2103 850 involving text (such as MathML content or form elements) should match
fantasai@2103 851 the replaced element's writing mode and line orientation if the UA
fantasai@2103 852 supports such a vertical writing mode for the replaced content.
fantasai@1774 853
fantasai@2302 854 <div class="example">
kojiishi@2763 855 <p>In the following example, two block elements (1 and 3) separated
fantasai@2302 856 by an image (2) are presented in various flow writing modes.</p>
fantasai@2302 857
fantasai@2302 858 <p>Here is a diagram of horizontal writing mode (<code>writing-mode: horizontal-tb</code>):</p>
fantasai@2302 859
fantasai@2302 860 <p><img alt="Diagram of horizontal layout: blocks 1, 2, and 3 are stacked top-to-bottom"
fantasai@2302 861 src="horizontal.png" width="219" height="300" ></p>
fantasai@2302 862
fantasai@2302 863 <p>Here is a diagram for the right-to-left vertical writing mode commonly
fantasai@2302 864 used in East Asia (<code>writing-mode: vertical-rl</code>):</p>
fantasai@2302 865
fantasai@2302 866 <p><img alt="Diagram of a right-to-left vertical layout: blocks 1, 2,
fantasai@2302 867 and 3 are arranged side by side from right to left"
fantasai@2302 868 src="vertical-rl.png" height="191" width="297" ></p>
fantasai@2302 869
fantasai@2302 870 <p>And finally, here is a diagram for the left-to-right vertical
fantasai@2302 871 writing mode used for Manchu and Mongolian (<code>writing-mode: vertical-lr</code>):</p>
fantasai@2302 872
fantasai@2302 873 <p><img alt="Diagram of left-to-right vertical layout: blocks 1, 2,
fantasai@2302 874 and 3 are arranged side by side from left to right"
fantasai@2302 875 src="vertical-lr.png" height="191" width="300" ></p>
fantasai@2302 876 </div>
fantasai@2971 877
fantasai@2971 878 <div class="example">
fantasai@2971 879 <p>In the following example, some form controls are rendered inside
fantasai@2971 880 a block with ''vertical-rl'' writing mode. The form controls are
fantasai@2971 881 rendered to match the writing mode.
fantasai@2971 882 <pre>
fantasai@2971 883 <!-- -->&lt;style>
fantasai@2971 884 <!-- --> form { writing-mode: vertical-rl; }
fantasai@2971 885 <!-- -->&lt;/style>
fantasai@2971 886 <!-- -->...
fantasai@2973 887 <!-- -->&lt;form>
fantasai@2973 888 <!-- -->&lt;p>&lt;label>姓名&#x3000;&lt;input value="艾俐俐">&lt;/label>
fantasai@2973 889 <!-- -->&lt;p>&lt;label>语文&#x3000;&lt;select>&lt;option>English
fantasai@2971 890 <!-- --> &lt;option>français
fantasai@2971 891 <!-- --> &lt;option>فارسی
fantasai@2973 892 <!-- --> &lt;option>中文
simon@6879 893 <!-- --> &lt;option>日本語&lt;/select>&lt;/label>
fantasai@2971 894 <!-- -->&lt;/form></pre>
fantasai@2971 895
fantasai@2971 896 <p><img alt="Screenshot of vertical layout: the input element is
fantasai@2971 897 laid lengthwise from top to bottom and its contents
kojiishi@4699 898 rendered in a vertical writing mode, matching the
fantasai@2971 899 labels outside it. The drop-down selection control
fantasai@6998 900 after it slides out to the side (towards the after
fantasai@2971 901 edge of the block) rather than downward as it would
fantasai@2971 902 in horizontal writing modes."
fantasai@2971 903 src="vertical-form.png"></p>
fantasai@2971 904 </div>
fantasai@2302 905
fantasai@2996 906 <div class="example">
fantasai@2996 907 <p>In this example, 'writing-mode' sets the list markers upright
fantasai@2996 908 using the ''::marker'' pseudo-element. Vertical alignment ensures
fantasai@2997 909 that longer numbers will still align with the right of the first
fantasai@2996 910 line of text. [[CSS3LIST]]
fantasai@2998 911 <pre>::marker { writing-mode: horizontal-tb;
fantasai@2998 912 <!-- --> vertical-align: text-top;
fantasai@2998 913 <!-- --> color: blue; }</pre>
fantasai@2996 914 <div class="figure">
fantasai@2996 915 <p><img alt="Diagram showing list markers of '1.', '2.', '3.' sitting
fantasai@2996 916 upright atop sideways vertical Latin list item text."
fantasai@2996 917 class="example" src="vertical-horizontal-list-markers.png">
fantasai@2996 918 <p class="caption">Example of horizontal list markers in a vertical list</p>
fantasai@2996 919 </div>
fantasai@2996 920 </div>
fantasai@2996 921
fantasai@2946 922 <h4 id="svg-writing-mode">
fantasai@2946 923 SVG1.1 'writing-mode' Values</h4>
fantasai@2946 924
fantasai@2946 925 <p>SVG1.1 [[!SVG11]] defines some additional values: ''lr'',
fantasai@3057 926 ''lr-tb'', ''rl'', ''rl-tb'', ''tb'', and ''tb-rl''.
fantasai@3056 927
fantasai@3056 928 <p>These values are <em>deprecated</em> in any context except SVG1 documents.
fantasai@3057 929 Implementations that wish to support these values in the context of CSS
fantasai@3057 930 must treat them as follows:
fantasai@2946 931
fantasai@2946 932 <table class="data">
fantasai@2946 933 <thead>
fantasai@3057 934 <tr><th>SVG1/Obsolete</th> <th>CSS</th></tr>
fantasai@2946 935 </thead>
fantasai@2946 936 <tbody>
fantasai@3056 937 <tr><td>''lr''</td> <td rowspan=3>''horizontal-tb''</td></tr>
fantasai@3056 938 <tr><td>''lr-tb''</td></tr>
fantasai@3056 939 <tr><td>''rl''</td></tr>
fantasai@3056 940 <tr><td>''tb''</td> <td rowspan=2>''vertical-rl''</td></tr>
fantasai@3056 941 <tr><td>''tb-rl''</td></tr>
fantasai@2946 942 </tbody>
fantasai@2946 943 </table>
fantasai@2946 944
fantasai@3057 945 <p class="note">The SVG1.1 values were also present in an older revision
fantasai@3057 946 of the CSS 'writing-mode' specification, which is obsoleted by this
fantasai@3057 947 specification. The additional ''tb-lr'' value of that revision is
fantasai@3057 948 replaced by ''vertical-lr''.
fantasai@3057 949
fantasai@2946 950 <p>In SVG1.1, these values set the <dfn>inline progression
fantasai@2946 951 direction</dfn>, in other words, the direction the current text position
fantasai@2946 952 advances each time a glyph is added. This is a geometric process that
fantasai@2946 953 happens <em>after</em> bidi reordering, and thus has no effect on the
fantasai@2946 954 interpretation of the 'direction' property (which is independent of
fantasai@2946 955 'writing-mode'). (See <a href="http://www.w3.org/TR/SVG/text.html#RelationshipWithBiDirectionality">Relationship
fantasai@2946 956 with bidirectionality</a>. [[!SVG11]])
fantasai@2946 957 <p class="note">There are varying interpretations
fantasai@2946 958 on whether this process causes "writing-mode: rl" to merely shift the
fantasai@2946 959 text string or reverse the order of all glyphs in the text.</p>
fantasai@2946 960
fantasai@2412 961 <h2 id="inline-alignment">
fantasai@2412 962 Inline-level Alignment</h2>
fantasai@2412 963
fantasai@2412 964 <p>When different kinds of inline-level content are placed together on a
fantasai@2412 965 line, the baselines of the content and the settings of the 'vertical-align'
fantasai@2412 966 property control how they are aligned in the transverse direction of the
fantasai@2412 967 line box. This section discusses what baselines are, how to find them,
fantasai@2412 968 and how they are used together with the 'vertical-align' property to
fantasai@2412 969 determine the alignment of inline-level content.
fantasai@2412 970
fantasai@2412 971 <h3 id="intro-baselines">
fantasai@2412 972 Introduction to Baselines</h3>
fantasai@2412 973
fantasai@2412 974 <p><em>This section is non-normative.</em></p>
fantasai@2412 975
fantasai@2412 976 <p>A <dfn>baseline</dfn> is a line along the <i>inline axis</i> of a line box
fantasai@2412 977 along which individual glyphs of text are aligned. Baselines guide the
fantasai@2412 978 design of glyphs in a font (for example, the bottom of most alphabetic
fantasai@2412 979 glyphs typically align with the alphabetic baseline), and they guide
fantasai@2412 980 the alignment of glyphs from different fonts or font sizes when typesetting.
fantasai@2412 981
fantasai@2412 982 <div class="figure">
fantasai@2414 983 [Picture of alphabetic text in two font sizes with the baseline and
fantasai@2414 984 emboxes indicated.]
fantasai@2412 985 </div>
fantasai@2412 986
fantasai@2412 987 <p>Different writing systems prefer different baseline tables.</p>
fantasai@2412 988
fantasai@2412 989 <div class="figure">
fantasai@2412 990 <p><img alt="Latin prefers the alphabetic baseline, on top of which most
fantasai@2412 991 letters rest, though some have descenders that dangle below it.
fantasai@2412 992 Indic scripts are sometimes typeset with a hanging baseline,
fantasai@2412 993 since their glyph shapes appear to be hanging from a
fantasai@2412 994 horizontal line.
fantasai@2412 995 Han-based systems, whose glyphs are designed to fill a square,
fantasai@2412 996 tend to align on their bottoms."
fantasai@2412 997 src="script-preferred-baselines.gif"></p>
fantasai@2412 998 <p class="caption">Preferred baselines in various writing systems</p>
fantasai@2412 999 </div>
fantasai@2412 1000
fantasai@2412 1001 <p>A well-constructed font contains a <dfn>baseline table</dfn>, which
fantasai@2412 1002 indicates the position of one or more baselines within the font's
fantasai@2414 1003 design coordinate space. (The design coordinate space is scaled with
fantasai@2414 1004 the font size.)
fantasai@2412 1005
fantasai@2412 1006 <div class="figure">
fantasai@2412 1007 <p><img alt=""
fantasai@2412 1008 src="baselines.gif"></p>
fantasai@2412 1009 <p class="caption">In a well-designed mixed-script font, the glyphs are
fantasai@2412 1010 positioned in the coordinate space to harmonize with one another
fantasai@2412 1011 when typeset together. The baseline table is then constructed to
fantasai@2412 1012 match the shape of the glyphs, each baseline positioned to match
fantasai@2412 1013 the glyphs from its preferred scripts.</p>
fantasai@2412 1014 </div>
fantasai@2412 1015
fantasai@2412 1016 <p>The baseline table is a property of the font, and the positions
fantasai@2412 1017 of the various baselines apply to all glyphs in the font.
fantasai@2412 1018
fantasai@2412 1019 <p>Different baseline tables can be provided for alignment in
fantasai@2946 1020 horizontal and vertical text. UAs should use the vertical
kojiishi@4699 1021 tables in vertical writing modes and the horizontal tables
fantasai@2946 1022 otherwise.
fantasai@2412 1023
fantasai@2412 1024 <h3 id="text-baselines">
fantasai@2412 1025 Text Baselines</h3>
fantasai@2412 1026
fantasai@2412 1027 <p>In this specification, only the following baselines are considered:
fantasai@2412 1028
fantasai@2412 1029 <dl>
fantasai@2412 1030 <dt>alphabetic</dt>
fantasai@2465 1031 <dd>The <dfn>alphabetic baseline</dfn>, which typically aligns with the
kojiishi@4699 1032 bottom of uppercase Latin glyphs.
fantasai@2465 1033
fantasai@2465 1034 </dd>
fantasai@2412 1035 <dt>central</dt>
fantasai@2465 1036 <dd>The <dfn>central baseline</dfn>, which typically crosses the center
kojiishi@4699 1037 of the em box. If the font is missing this baseline,
fantasai@2412 1038 it is assumed to be halfway between the ascender (<i>over</i>)
fantasai@2465 1039 and descender (<i>under</i>) edges of the em box.
fantasai@2465 1040 </dd>
fantasai@2412 1041 </dl>
fantasai@2412 1042
kojiishi@4699 1043 <p>In vertical writing mode, the <i>central baseline</i> is used as the
fantasai@7004 1044 dominant baseline when 'text-orientation' is ''mixed'' or ''upright''.
kojiishi@4699 1045 Otherwise the <i>alphabetic baseline</i> is used.
kojiishi@4699 1046
fantasai@2412 1047 <p class="note">A future CSS module will deal with baselines in more
fantasai@2412 1048 detail and allow the choice of other dominant baselines and alignment
fantasai@2412 1049 options.</p>
fantasai@2412 1050
fantasai@2412 1051 <h3 id="replaced-baselines">
fantasai@2412 1052 Atomic Inline Baselines</h3>
fantasai@2412 1053
fantasai@2412 1054 <p>If an <a href="http://www.w3.org/TR/CSS21/visuren.html#inline-boxes">atomic
fantasai@2412 1055 inline</a> (such as an inline-block, inline-table, or replaced inline element)
fantasai@2412 1056 is not capable of providing its own baseline information, then the
fantasai@2412 1057 UA synthesizes a baseline table thus:
fantasai@2412 1058
fantasai@2412 1059 <dl>
fantasai@2412 1060 <dt>alphabetic</dt>
fantasai@2412 1061 <dd>The alphabetic baseline is assumed to be at the <i>under</i>
fantasai@2412 1062 margin edge.</dd>
fantasai@2412 1063 <dt>central</dt>
fantasai@2412 1064 <dd>The central baseline is assumed to be halfway between the
fantasai@2415 1065 <i>under</i> and <i>over</i> margin edges of the box.
fantasai@2412 1066 </dl>
fantasai@2412 1067
fantasai@2412 1068 <h3 id="baseline-alignment">
fantasai@2412 1069 Baseline Alignment</h3>
fantasai@2412 1070
fantasai@2994 1071 <p>The <dfn>dominant baseline</dfn>
fantasai@2994 1072 (which <a href="#text-baselines">can change</a> based on the writing mode)
fantasai@2994 1073 is used in CSS for alignment in two cases:
fantasai@2412 1074 <ul>
fantasai@2994 1075 <li><strong>Aligning glyphs from different fonts within the same inline box.</strong>
fantasai@2412 1076 The glyphs are aligned by matching up the positions of the dominant
fantasai@2994 1077 baseline in their corresponding fonts.
fantasai@2994 1078 <li><strong>Aligning a child inline-level box within its parent.</strong>
fantasai@2994 1079 For the 'vertical-align' value of ''baseline'', child is aligned to
fantasai@2412 1080 the parent by matching the parent's dominant baseline to the same
fantasai@2412 1081 baseline in the child. (E.g. if the parent's dominant baseline is
fantasai@2412 1082 alphabetic, then the child's alphabetic baseline is matched to the
fantasai@2412 1083 parent's alphabetic baseline, even if the child's dominant baseline
fantasai@2412 1084 is something else.)
fantasai@2994 1085 For values of ''sub'', ''super'', ''&lt;length&gt;'', and
fantasai@2994 1086 ''&lt;percentage&gt;'', the baselines are aligned as for ''baseline'',
fantasai@2994 1087 but the child is shifted according to the offset given by its
fantasai@2994 1088 'vertical-align' value.
fantasai@2412 1089 <div class="example">
fantasai@2412 1090 <p>Given following sample markup:
fantasai@2415 1091 <pre>&lt;p&gt;&lt;span class="outer"&gt;Ap &lt;span class="inner"&gt;<i>ji</i>&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;</pre>
fantasai@2412 1092 <p>And the following style rule:
fantasai@2412 1093 <pre>span.inner { font-size: .75em; }</pre>
fantasai@2412 1094 <p>The baseline tables of the parent (<code>.outer</code>) and the child
kojiishi@2622 1095 (<code>.inner</code>) will not match up due to the font size difference.
fantasai@2412 1096 Since the dominant baseline is the alphabetic baseline, the child box
fantasai@2412 1097 is aligned to its parent by matching up their alphabetic baselines.
fantasai@2412 1098 <div class="figure">
fantasai@2412 1099 <p><img alt="" src="baseline-align-sizes.gif">
fantasai@2412 1100 </div>
fantasai@2412 1101 </div>
fantasai@2412 1102
fantasai@2412 1103 <div class="example">
fantasai@2412 1104 <p>If we assign ''vertical-align: super'' to the <code>.inner</code>
fantasai@2412 1105 element from the example above, the same rules are used to align
fantasai@2412 1106 the <code>.inner</code> child to its parent; the only difference
fantasai@2412 1107 is in addition to the baseline alignment, the child is shifted to
kojiishi@2622 1108 the superscript position.
fantasai@2412 1109 <pre>span.inner { vertical-align: super; font-size: .75em; }</pre>
fantasai@2412 1110 <div class="figure">
fantasai@2412 1111 <p><img alt="In this example, the resulting alignment is equivalent
fantasai@2412 1112 to shifting the parent baseline table upwards by the
fantasai@2412 1113 superscript offset, and then aligning the child's
fantasai@2412 1114 alphabetic baseline to the shifted position of the
fantasai@2412 1115 parent's alphabetic baseline."
fantasai@2412 1116 src="baseline-align-super.gif">
fantasai@2412 1117 </div>
fantasai@2412 1118 </div>
fantasai@2412 1119 </ul>
fantasai@2412 1120
fantasai@2304 1121 <h2 id="intro-text-layout">
fantasai@2946 1122 Introduction to Vertical Text Layout</h2>
fantasai@2067 1123
fantasai@2478 1124 <p>Each writing system has one or more native orientations. Modern scripts
fantasai@2478 1125 can therefore be classified into three orientational categories:</p>
fantasai@2355 1126
fantasai@2478 1127 <dl>
fantasai@2478 1128 <dt>horizontal-only</dt>
fantasai@2478 1129 <dd>Scripts that have horizontal, but not vertical, native orientation.
fantasai@2478 1130 Includes: Latin, Arabic, Hebrew, Devanagari
fantasai@2478 1131 <dt>vertical-only</dt>
fantasai@2478 1132 <dd>Scripts that have vertical, but not horizontal, native orientation.
fantasai@2858 1133 Includes: Mongolian, Phags Pa
fantasai@2478 1134 <dt>bi-orientational</dt>
fantasai@2478 1135 <dd>Scripts that have both vertical and horizontal native orientation.
fantasai@2478 1136 Includes: Han, Hangul, Japanese Kana
fantasai@2478 1137 </dl>
fantasai@2478 1138
fantasai@3639 1139 <p>A <dfn>vertical script</dfn> is one that has a native vertical orientation:
fantasai@3639 1140 i.e. one that is either vertical-only or that is bi-orientational.
fantasai@3639 1141 A <dfn>horizontal script</dfn> is one that has a native horizontal orientation:
fantasai@3639 1142 i.e. one that is either horizontal-only or that is bi-orientational.
fantasai@5566 1143 (See <a href="#script-orientations">Appendix B</a> for a categorization of
fantasai@5566 1144 scripts by native orientation.)
fantasai@3639 1145
fantasai@3639 1146 <div class="figure">
fantasai@3639 1147 <p><img alt="A Venn diagram of these distinctions would show two circles:
fantasai@4220 1148 one labelled 'vertical', the other 'horizontal'. The overlapped
fantasai@3639 1149 region would represent the bi-orientational scripts, while
fantasai@3639 1150 horizontal-only and vertical-only scripts would occupy their
fantasai@3639 1151 respective circles' exclusive regions."
fantasai@3639 1152 src="baseline-align-super.gif">
fantasai@3639 1153 </div>
fantasai@3639 1154
fantasai@2478 1155 <p>In modern typographic systems, all glyphs are assigned a horizontal
fantasai@2478 1156 orientation, which is used when laying out text horizontally.
fantasai@2478 1157 To lay out vertical text, the UA needs to transform the text from its
fantasai@2478 1158 horizontal orientation. This transformation is the <dfn>bi-orientational
fantasai@2478 1159 transform</dfn>, and there are two types:
fantasai@2478 1160
fantasai@2478 1161 <dl>
fantasai@2478 1162 <dt>rotate</dt>
fantasai@2478 1163 <dd>Rotate the glyph from horizontal to vertical
fantasai@2901 1164 <a href="diagrams/glyph-right.svg" type="image/svg+xml">
kojiishi@2935 1165 <img src="diagrams/glyph-right.png" class="figure"
smurakam@2968 1166 alt="Rotate the glyph from horizontal to vertical"></a>
fantasai@2478 1167
fantasai@2478 1168 <dt>translate</dt>
fantasai@2478 1169 <dd>Translate the glyph from horizontal to vertical
fantasai@2901 1170 <a href="diagrams/glyph-upright.svg" type="image/svg+xml">
kojiishi@2935 1171 <img src="diagrams/glyph-upright.png" class="figure"
kojiishi@2935 1172 alt="Translate the glyph from horizontal to vertical"></a>
fantasai@2478 1173 </dl>
fantasai@2478 1174
fantasai@2478 1175 <p>Scripts with a native vertical orientation have an
fantasai@2478 1176 intrinsic bi-orientational transform, which orients them correctly in
fantasai@5566 1177 vertical text: most CJK (Chinese/Japanese/Korean) characters translate,
fantasai@5566 1178 that is, they are always upright. Characters from other scripts,
fantasai@5566 1179 such as Mongolian, rotate.
fantasai@2478 1180
fantasai@2501 1181 <p>Scripts without a native vertical orientation can be either rotated
fantasai@2501 1182 (set sideways) or translated (set upright): the transform used is a
fantasai@2501 1183 stylistic preference depending on the text's usage, rather than a
fantasai@2501 1184 matter of correctness.
fantasai@7004 1185 The 'text-orientation' property's ''mixed'' and ''upright'' values
fantasai@2478 1186 are provided to specify rotation vs. translation of horizontal-only text.
fantasai@2478 1187
fantasai@2955 1188 <p class="note">The ''sideways-left'', ''sideways-right'', and ''sideways''
fantasai@2478 1189 values of 'text-orientation' are provided for decorative layout effects
fantasai@2478 1190 and to work around limitations in CSS support for bottom-to-top scripts.
fantasai@2478 1191
fantasai@2478 1192 <h3 id="text-orientation">
fantasai@2478 1193 Orienting Text: the 'text-orientation' property</h3>
fantasai@2026 1194
fantasai@2026 1195 <table class="propdef">
fantasai@2026 1196 <tbody>
fantasai@2026 1197 <tr>
fantasai@2026 1198 <th>Name:</th>
fantasai@2026 1199 <td><dfn>text-orientation</dfn></td>
fantasai@2026 1200 </tr>
fantasai@2026 1201 <tr>
fantasai@5315 1202 <th><a href="#values">Value</a>:</th>
fantasai@7004 1203 <td>mixed | upright | sideways-right | sideways-left | sideways
fantasai@2958 1204 | use-glyph-orientation
fantasai@2026 1205 </tr>
fantasai@2026 1206 <tr>
fantasai@2026 1207 <th>Initial:</th>
fantasai@7004 1208 <td>mixed</td>
fantasai@2026 1209 </tr>
fantasai@2026 1210 <tr>
fantasai@2026 1211 <th>Applies to:</th>
fantasai@2026 1212 <td>all elements except table row groups, rows, column groups, and columns</td>
fantasai@2026 1213 </tr>
fantasai@2026 1214 <tr>
fantasai@2026 1215 <th>Inherited:</th>
fantasai@2026 1216 <td>yes</td>
fantasai@2026 1217 </tr>
fantasai@2026 1218 <tr>
fantasai@2026 1219 <th>Percentages:</th>
fantasai@2026 1220 <td>N/A</td>
fantasai@2026 1221 </tr>
fantasai@2026 1222 <tr>
fantasai@2026 1223 <th>Media:</th>
fantasai@2026 1224 <td>visual</td>
fantasai@2026 1225 </tr>
fantasai@2026 1226 <tr>
fantasai@2026 1227 <th>Computed&#160;value:</th>
fantasai@2026 1228 <td>specified value</td>
fantasai@2026 1229 </tr>
fantasai@2026 1230 </tbody>
fantasai@2026 1231 </table>
fantasai@2026 1232
kojiishi@4699 1233 <p>This property specifies the orientation of text
fantasai@3639 1234 within a line. Current values only have an effect in vertical writing
fantasai@3639 1235 modes; the property has no effect on elements in horizontal writing modes.
fantasai@2820 1236
fantasai@2993 1237 <p>For readability, the term <i>character</i> is used in place of
fantasai@2993 1238 <em>extended grapheme cluster</em> in this section.
fantasai@2993 1239 See <a href="#character-properties">Characters and Properties</a>
fantasai@2993 1240 for further details.
fantasai@2820 1241
fantasai@2820 1242 <p>Values have the following meanings:</p>
fantasai@2026 1243
fantasai@2026 1244 <dl>
fantasai@7004 1245 <dt><dfn>mixed</dfn></dt>
fantasai@2820 1246 <dd><p>In vertical writing modes, characters from horizontal-only
fantasai@2501 1247 scripts are set sideways, i.e. 90&deg; clockwise from their standard
fantasai@2501 1248 orientation in horizontal text.
fantasai@2478 1249 Characters from vertical scripts are set with their intrinsic orientation.
kojiishi@6058 1250 See <a href="#vertical-orientations">Vertical Orientations</a> for further details.
kojiishi@4699 1251 <p>This value is typical for layout of primarily vertical-script text.
fantasai@2049 1252 <dt><dfn>upright</dfn></dt>
fantasai@4220 1253 <dd><p>In vertical writing modes, characters from horizontal-only
fantasai@2478 1254 scripts are rendered upright, i.e. in their standard horizontal
fantasai@2478 1255 orientation.
fantasai@2478 1256 Characters from vertical scripts are set with their intrinsic orientation
fantasai@2478 1257 and shaped normally.
kojiishi@6058 1258 See <a href="#vertical-orientations">Vertical Orientations</a> for further details.
fantasai@2047 1259 <p>For the purposes of bidi reordering, this value causes all
fantasai@2047 1260 characters to be treated as strong LTR.
fantasai@2047 1261 This value causes the used value of 'direction' to be ''ltr''.
fantasai@2955 1262 <dt><dfn>sideways-right</dfn></dt>
fantasai@2049 1263 <dd><p>In vertical writing modes, this causes text to be set as if
fantasai@5564 1264 in a horizontal layout, but rotated 90&deg; clockwise.
fantasai@2955 1265 <dt><dfn>sideways-left</dfn></dt>
fantasai@2049 1266 <dd><p>In vertical writing modes, this causes text to be set as if
fantasai@5564 1267 in a horizontal layout, but rotated 90&deg; counter-clockwise.
fantasai@2955 1268 <p>If set on a non-replaced inline whose parent is not ''sideways-left'',
fantasai@2992 1269 this forces bidi isolation: the ''normal'' and ''embed'' values of
fantasai@2992 1270 'unicode-bidi' compute to ''isolate'', and ''bidi-override'' computes
fantasai@7005 1271 to ''isolate-override''.
fantasai@2955 1272 Layout of text is exactly as for ''sideways-right'' except that the
fantasai@7006 1273 baseline table of each of the element's inline boxes
fantasai@7006 1274 is mirrored around a vertical axis along the center of its content box
fantasai@7006 1275 and text layout is rotated 180&deg; to match.
fantasai@2567 1276 The positions of text decorations propagated from an ancestor inline
fantasai@2567 1277 (including the block container's root inline) are not mirrored, but any
fantasai@2567 1278 text decorations introduced by the element are positioned using the
fantasai@2567 1279 mirrored baseline table.
fantasai@2567 1280 <p>Similarly, if an inline child of the element has a 'text-orientation'
fantasai@2992 1281 value other than ''sideways-left'', an analogous transformation (and
fantasai@2992 1282 bidi isolation) is applied.
fantasai@2955 1283 <dt><dfn>sideways</dfn></dt>
fantasai@2955 1284 <dd><p>This value is equivalent to ''sideways-right'' in ''vertical-rl''
fantasai@2955 1285 writing mode and equivalent to ''sideways-left'' in ''vertical-lr''
fantasai@2501 1286 writing mode. It can be useful when setting horizontal script text
fantasai@2501 1287 vertically in a primarily horizontal-only document.
fantasai@2958 1288 <dt><dfn>use-glyph-orientation</dfn></dt>
fantasai@2178 1289 <dd><p>[[!SVG11]] defines 'glyph-orientation-vertical' and
fantasai@2178 1290 'glyph-orientation-horizontal' properties that were intended to control
fantasai@2178 1291 text orientation. These properties are <em>deprecated</em> and do not
fantasai@2178 1292 apply to non-SVG elements. If an implementation supports these properties,
fantasai@2958 1293 the ''use-glyph-orientation'' value when set on SVG elements indicates
fantasai@2958 1294 that the SVG
fantasai@2958 1295 'glyph-orientation-vertical' and 'glyph-orientation-horizontal'
fantasai@2958 1296 behavior control the layout of text. Such UAs must set
fantasai@7007 1297 ''text-orientation: use-glyph-orientation'' on all
fantasai@2178 1298 <a href="http://www.w3.org/TR/SVG/intro.html#TermTextContentElement">SVG
fantasai@2178 1299 text content elements</a> in their default UA style sheet for SVG.
fantasai@2178 1300 <p>In all other contexts, and for implementations that do not support
fantasai@2958 1301 the glyph orientation properties, the ''use-glyph-orientation'' behavior
fantasai@7004 1302 is the same as for ''mixed''.
fantasai@2958 1303 <p class="note">This value is at-risk and may be dropped during CR.
fantasai@2026 1304 </dl>
fantasai@2026 1305
fantasai@5653 1306 <div class="figure" id="fig-text-orientation">
fantasai@5653 1307 <table class=data>
kojiishi@3043 1308 <tr>
kojiishi@3043 1309 <td>
kojiishi@3043 1310 <img
fantasai@7004 1311 alt="text-orientation: mixed"
kojiishi@3049 1312 src="text-orientation-vr.png" width="64" height="160" >
kojiishi@3043 1313 </td>
kojiishi@3043 1314 <td>
kojiishi@3043 1315 <img
kojiishi@3043 1316 alt="text-orientation: upright"
kojiishi@3049 1317 src="text-orientation-up.png" width="64" height="160" >
kojiishi@3043 1318 </td>
kojiishi@3043 1319 <td>
kojiishi@3043 1320 <img
kojiishi@3043 1321 alt="text-orientation: sideways-left"
kojiishi@3049 1322 src="text-orientation-sl.png" width="64" height="160" >
kojiishi@3043 1323 </td>
kojiishi@3043 1324 <td>
kojiishi@3043 1325 <img
kojiishi@3043 1326 alt="text-orientation: sideways-right"
kojiishi@3049 1327 src="text-orientation-sr.png" width="64" height="160" >
kojiishi@3043 1328 </td>
kojiishi@3043 1329 </tr>
kojiishi@3043 1330 <tr>
fantasai@7004 1331 <td>''mixed''</td>
kojiishi@3043 1332 <td>''upright''</td>
kojiishi@3043 1333 <td>''sideways-left''</td>
kojiishi@3043 1334 <td>''sideways-right''</td>
kojiishi@3043 1335 </tr>
kojiishi@3043 1336 </table>
kojiishi@3049 1337 <p class="caption">'text-orientation' values ('writing-mode' is ''vertical-rl'')</p>
kojiishi@2261 1338 </div>
fantasai@2026 1339
fantasai@2501 1340 <div class="example">
fantasai@2501 1341 <p>In the following example, the root element of a horizontal-only document
fantasai@2955 1342 is set to use ''sideways''. In the rest of the document, the author
fantasai@2501 1343 can just set 'writing-mode' without worrying about whether the text is
fantasai@2501 1344 ''vertical-rl'' or ''vertical-lr''.
fantasai@2501 1345 <pre>
fantasai@2955 1346 :root { text-orientation: sideways; }
fantasai@2501 1347 caption { caption-side: left; writing-mode: vertical-lr; }
fantasai@2501 1348 thead th { writing-mode: vertical-lr; }
fantasai@2501 1349 h1.banner { position: absolute; top: 0; right: 0; writing-mode: vertical-rl; }
fantasai@2501 1350 </pre>
fantasai@2501 1351 </div>
fantasai@2501 1352
fantasai@5564 1353 <p class="note">Changing the value of this property may affect inline-level alignment.
kojiishi@4699 1354 Refer to <a href="#text-baselines">Text Baselines</a> for more details.</p>
kojiishi@4699 1355
jackalmage@6851 1356 <h4 id='vertical-orientations'>
jackalmage@6853 1357 Mixed Vertical Orientations</h4>
jackalmage@6851 1358
kojiishi@6103 1359 <p>
koji@8473 1360 [[!UTR50]] defines the Vertical_Orientation property for the default character orientation of mixed-orientation vertical text.
fantasai@7004 1361 When 'text-orientation' is ''mixed'',
fantasai@7003 1362 the UA must render a <i>character</i> upright if its orientation property is
koji@8473 1363 <code>U</code>, <code>Tx</code>, or <code>Tu</code>;
fantasai@7003 1364 or <a href="#typeset-sideways">typeset it sideways</a> (90&deg; clockwise from horizontal)
fantasai@7003 1365 if its orientation property is <code>R</code>.
fantasai@7003 1366 For <code>Tr</code> <i>characters</i>,
fantasai@7003 1367 which are intended to be either transformed or rotated sideways,
fantasai@7003 1368 the UA may assume that appropriate glyphs for upright typesetting
fantasai@7003 1369 are given in the font and render them upright;
fantasai@7003 1370 alternately it may check for such glyphs first,
fantasai@7003 1371 and fall back to typesetting them sideways if the appropriate glyphs are missing.
jackalmage@6851 1372
fantasai@7008 1373 <p>
fantasai@7008 1374 In some systems (e.g. when using OpenType fonts),
fantasai@7008 1375 to correctly orient a <i>character</i> belonging to the Mongolian or Phags-pa script upright,
fantasai@7008 1376 the UA must actually typeset it <a href="#typeset-sideways">sideways</a>.
fantasai@7008 1377 <p class="note">This is because the "upright" orientation
fantasai@7008 1378 in the Unicode code charts (which assume vertical typesetting)
fantasai@7008 1379 and the "upright" orientation of the glyphs of these scripts
fantasai@7008 1380 in most OpenType fonts (which assume horizontal typesetting)
fantasai@7008 1381 don't match.
kojiishi@6103 1382
jackalmage@6851 1383 <h4 id='vertical-font-features'>
fantasai@5651 1384 Vertical Typesetting and Font Features</h4>
fantasai@5564 1385
fantasai@7004 1386 <p>When typesetting text in ''mixed'' and ''upright'' orientations:
fantasai@5652 1387
jackalmage@6852 1388 <dl>
jackalmage@6852 1389 <dt>upright characters
jackalmage@6852 1390 <dd>
fantasai@7008 1391 Are typeset upright with vertical font metrics.
fantasai@5652 1392 The UA must synthesize vertical font metrics for fonts that lack them.
fantasai@5652 1393 (This specification does not define heuristics for synthesizing such metrics.)
fantasai@7008 1394 Additionally, font features (such as alternate glyphs and other transformation)
fantasai@7008 1395 intended for use in vertical typesetting must be used.
fantasai@5652 1396 (E.g. the OpenType ''vert'' feature must be enabled.)
fantasai@5652 1397 Furthermore, characters from horizontal cursive scripts (such as Arabic)
fantasai@5652 1398 are shaped in their isolated forms when typeset upright.
jackalmage@6852 1399 <p class="note">Note that even when typeset "upright",
jackalmage@6852 1400 some glyphs should appear rotated.
jackalmage@6852 1401 For example, dashes and enclosing punctuation
jackalmage@6852 1402 (such as 〈 LEFT ANGLE BRACKET U+3008)
jackalmage@6852 1403 should be oriented relative to the inline axis.
jackalmage@6852 1404 In OpenType, this is typically handled by glyph substitution,
jackalmage@6852 1405 although not all fonts have alternate glyphs for all relevant codepoints.
jackalmage@6852 1406 (East Asian fonts usually provide alternates for East Asian codepoints,
jackalmage@6852 1407 but Western fonts typically lack any vertical typesetting features.)
jackalmage@6852 1408 Unicode published draft data on which <i>characters</i> should appear sideways
jackalmage@6852 1409 as the SVO property in <a href="http://www.unicode.org/reports/tr50/tr50-6.Orientation.txt">this data file</a>;
koji@8473 1410 however, this property has been abandoned for the current revision of [[!UTR50]].
jackalmage@6852 1411 <dt id='typeset-sideways'>sideways characters
jackalmage@6852 1412 <dd>
fantasai@7008 1413 Are typeset rotated 90&deg; sideways with horizontal metrics,
fantasai@5652 1414 and vertical typesetting features are not used.
fantasai@5652 1415 However, if the font has features meant to be enabled
fantasai@5652 1416 for sideways text that is typeset in vertical lines
fantasai@5652 1417 (e.g. to adjust brush stroke angles or alignment),
fantasai@5652 1418 those features are used.
jackalmage@6852 1419 <!--<p class="issue">Propose 'svrt' as an OpenType substitution feature
fantasai@5652 1420 that is applied to rotated horizontal text in vertical text runs,
jackalmage@6852 1421 to handle these cases.-->
jackalmage@6852 1422 </dl>
fantasai@5652 1423
jackalmage@6851 1424 <p>
jackalmage@6852 1425 All text in ''sideways'', ''sideways-right'', and ''sideways-left'' orientations is
jackalmage@6851 1426 typeset using horizontal font metrics and the normal set of features
jackalmage@6851 1427 used for horizontal text runs.
jackalmage@6851 1428 Vertical metrics, vertical glyph variations, and any other features meant
jackalmage@6851 1429 for text typeset in vertical lines are <em>not</em> used.
jackalmage@6851 1430
fantasai@7003 1431 <p class="note">
fantasai@7003 1432 The OpenType ''vrt2'' feature, which is intended for mixed-orientation typesetting,
fantasai@7003 1433 is not used by CSS.
fantasai@7003 1434 It delegates the responsibility for orienting glyphs to the font designer.
fantasai@7003 1435 CSS instead dictates the orientation through [[!UTR50]]
fantasai@7003 1436 and orients glyphs by typesetting them sideways or upright as appropriate.
fantasai@7003 1437
fantasai@5652 1438 <p class=issue>This section needs additional work. Suggestions are welcome.
fantasai@5564 1439
fantasai@4120 1440 <!-- random notes
fantasai@4120 1441 Property to customize text-orientation (and line breaking class) of various
fantasai@4120 1442 characters (yes, the name is horrible, we need a better one):
fantasai@4120 1443 text-symbolize: latin ||
fantasai@4120 1444 greek ||
fantasai@4120 1445 cyrillic ||
fantasai@4120 1446 letter-symbols || /* letterlike symbols and math letters */
fantasai@4120 1447 arrows || /* and math relation operators?? */
fantasai@4120 1448 currency || /* Sc */
fantasai@4120 1449 rotate-symbols || /* other So */
fantasai@4120 1450
fantasai@4120 1451 Do symbols NFC-fold to Latin/Greek? If so we might have a problem there.
fantasai@4120 1452
fantasai@4120 1453 Roman numerals are poorly handled right now. If we make them upright, we
fantasai@4120 1454 get the right behavior in most cases. But as soon as you get to 13, you
fantasai@4120 1455 have a problem.
fantasai@4120 1456 -->
fantasai@4120 1457
fantasai@2304 1458 <h2 id="abstract-box">
fantasai@2304 1459 Abstract Box Terminology</h2>
smurakam@1826 1460
fantasai@3923 1461 <p>CSS2.1 [[!CSS21]] defines the box layout model of CSS in detail,
fantasai@3923 1462 but only for the ''horizontal-tb'' writing mode. Layout is analogous
fantasai@3923 1463 in writing modes other than ''horizontal-tb''; however directional
fantasai@3923 1464 and dimensional terms in CSS2.1 must be abstracted and remapped
fantasai@3923 1465 appropriately.
fantasai@3923 1466
fantasai@3923 1467 <p>This section defines abstract directional and dimensional terms and
fantasai@3923 1468 their mappings in order to define box layout for other writing modes,
fantasai@3923 1469 and to provide terminology for future specs to define their layout
fantasai@3923 1470 concepts abstractly. (The next section explains how to apply them to
fantasai@3923 1471 CSS2.1 layout calculations and how to handle
fantasai@3923 1472 <a href="#orthogonal-flows">orthogonal flows</a>.)
fantasai@3923 1473 Although they derive from the behavior of text, these abstract
fantasai@3923 1474 mappings exist even for boxes that do not contain any line boxes:
fantasai@3923 1475 they are calculated directly from the values of the 'writing-mode',
fantasai@3923 1476 'text-orientation', and 'direction' properties.
fantasai@3923 1477
fantasai@3923 1478 <p>There are three sets of directional terms in CSS:
fantasai@3923 1479
fantasai@3923 1480 <dl>
fantasai@3923 1481 <dt>physical
fantasai@3923 1482 <dd>Interpreted relative to the page, independent of writing mode.
fantasai@3923 1483 The physical directions are <i>left</i>, <i>right</i>, <i>top</i>, and
fantasai@3923 1484 <i>bottom</i>.
fantasai@5653 1485 <dt><a href="#logical-directions">flow-relative</a>
fantasai@8130 1486 <dd>Interpreted relative to the flow of content.
fantasai@8130 1487 The flow-relative directions are <i>start</i> and <i>end</i>,
fantasai@8130 1488 or <i>block-start</i>, <i>block-end</i>, <i>inline-start</i>, and <i>inline-end</i>
fantasai@8130 1489 if the dimension is also ambiguous.
fantasai@5653 1490 <dt><a href="#line-directions">line-relative</a>
fantasai@3923 1491 <dd>Interpreted relative to the orientation of the line box.
fantasai@3923 1492 The line-relative directions are <i>line-left</i>, <i>line-right</i>,
fantasai@3923 1493 <i>over</i>, and <i>under</i>.
fantasai@3923 1494 </dl>
fantasai@3923 1495
fantasai@3923 1496 <p>The <dfn>physical dimensions</dfn> are <i>width</i> and <i>height</i>,
fantasai@3923 1497 which correspond to measurements along the <i>x-axis</i>
fantasai@3923 1498 (<i>vertical dimension</i>) and <i>y-axis</i> (<i>horizontal dimension</i>),
fantasai@5653 1499 respectively. <a href="#abstract-dimensions">Abstract dimensions</a>
fantasai@3923 1500 are identical in both flow-relative and line-relative terms, so there
fantasai@3923 1501 is only one set of these terms.
fantasai@365 1502
fantasai@8130 1503 <p class="note">
fantasai@8130 1504 Note: [[CSS-FLEXBOX]] also defines <a href="http://www.w3.org/TR/css3-flexbox/#box-model">flex-relative terms</a>,
fantasai@8130 1505 which are used in describing flex layout.
fantasai@8130 1506
fantasai@2304 1507 <h3 id="abstract-dimensions">
fantasai@3923 1508 Abstract Dimensions</h3>
fantasai@3923 1509
fantasai@3923 1510 <p>The <dfn>abstract dimensions</dfn> are defined below:
fantasai@2103 1511
fantasai@1767 1512 <dl>
fantasai@3923 1513 <dt><dfn>block dimension</dfn></dt>
simon@8439 1514 <dd>The dimension perpendicular to the flow of text within a line, i.e.
fantasai@2103 1515 the <i>vertical dimension</i> in horizontal writing modes, and
fantasai@2103 1516 the <i>horizontal dimension</i> in vertical writing modes.</dd>
fantasai@2103 1517 <dt><dfn>inline dimension</dfn></dt>
fantasai@2103 1518 <dd>The dimension parallel to the flow of text within a line, i.e.
fantasai@2103 1519 the <i>horizontal dimension</i> in horizontal writing modes, and
fantasai@2103 1520 the <i>vertical dimension</i> in vertical writing modes.</dd>
fantasai@6857 1521 <dt><dfn>block-axis</dfn></dt>
fantasai@3923 1522 <dd>The axis in the block dimension, i.e. the <i>vertical
fantasai@2103 1523 axis</i> in horizontal writing modes and the <i>horizontal
fantasai@2103 1524 axis</i> in vertical writing modes.</dd>
fantasai@6857 1525 <dt><dfn>inline-axis</dfn></dt>
fantasai@2103 1526 <dd>The axis in the inline dimension, i.e. the <i>horizontal
fantasai@2103 1527 axis</i> in horizontal writing modes and the <i>vertical axis</i>
fantasai@2103 1528 in vertical writing modes.</dd>
fantasai@2585 1529 <dt><dfn>extent</dfn> or <dfn>logical height</dfn><dt>
fantasai@3923 1530 <dd>A measurement in the block dimension: refers to the
fantasai@2103 1531 physical height (vertical dimension) in horizontal writing
fantasai@2103 1532 modes, and to the physical width (horizontal dimension) in
fantasai@2103 1533 vertical writing modes.</dd>
fantasai@2103 1534 <dt><dfn>measure</dfn> or <dfn>logical width</dfn><dt>
fantasai@2103 1535 <dd>A measurement in the inline dimension: refers to the
fantasai@2103 1536 physical width (horizontal dimension) in horizontal writing
fantasai@2103 1537 modes, and to the physical height (vertical dimension) in
fantasai@2103 1538 vertical writing modes. (The term <i>measure</i> derives
fantasai@2110 1539 from its <a href="http://en.wikipedia.org/wiki/Measure_%28typography%29">use
fantasai@2110 1540 in typography</a>.)</dd>
fantasai@1767 1541 </dl>
fantasai@2103 1542
fantasai@2304 1543 <h3 id="logical-directions">
fantasai@2304 1544 Flow-relative Directions</h3>
fantasai@2103 1545
fantasai@8130 1546 <p>The <dfn>flow-relative directions</dfn>,
fantasai@8130 1547 <i>block-start</i>, <i>block-end</i>, <i>inline-start</i>, and <i>inline-end</i>,
fantasai@8130 1548 are defined relative to the flow of content on the page.
fantasai@3923 1549 In an <abbr title="left-to-right">LTR</abbr>
fantasai@2103 1550 ''horizontal-tb'' writing mode, they correspond to the
fantasai@8130 1551 top, bottom, left, and right directions, respectively.
fantasai@8130 1552 They are defined as follows:
fantasai@3924 1553
fantasai@3924 1554 <dl>
fantasai@8130 1555 <dt><dfn>block-start</dfn>
fantasai@3924 1556 <dd>Nominally the side that comes earlier in the block progression,
fantasai@8130 1557 as determined by the 'writing-mode' property:
fantasai@8130 1558 the physical top in ''horizontal-tb'' mode,
fantasai@8130 1559 the right in ''vertical-rl'', and the left in ''vertical-lr''.
fantasai@8130 1560 <dt><dfn>block-end</dfn>
fantasai@8130 1561 <dd>The side opposite <i>block-start</i>.
fantasai@8130 1562 <dt><dfn>inline-start</dfn>
fantasai@8130 1563 <dd>Nominally the side from which text of its inline base direction will start.
fantasai@8130 1564 For boxes with a used 'direction' value of ''ltr'', this means the <i>line-left</i> side.
fantasai@8130 1565 For boxes with a used 'direction' value of ''rtl'', this means the <i>line-right</i> side.
fantasai@8130 1566 <dt><dfn>inline-end</dfn>
fantasai@4120 1567 <dd>The side opposite <i>start</i>.
fantasai@3924 1568 </dl>
fantasai@2304 1569
fantasai@8130 1570 <p>Where unambiguous (or dual-meaning),
fantasai@8130 1571 the terms <dfn>start</dfn> and <dfn>end</dfn>
fantasai@8130 1572 are used in place of <i>block-start</i>/<i>inline-start</i>
fantasai@8130 1573 and <i>block-end</i>/<i>inline-end</i>, respectively.
fantasai@8130 1574
fantasai@8130 1575 <p class="note">Note that while determining the <i>block-start</i> and
fantasai@8130 1576 <i>block-end</i> sides of a box depends only on the 'writing-mode' property,
fantasai@8130 1577 determining the <i>inline-start</i> and <i>inline-end</i> sides of a box depends
fantasai@8130 1578 not only on the 'writing-mode' property but also the 'direction' <em>and</em>
fantasai@2304 1579 'text-orientation' properties.</p>
fantasai@365 1580
fantasai@1767 1581 <div class="example">
fantasai@1767 1582 <p>An English (LTR-TB) block:</p>
fantasai@1767 1583 <pre class="ascii-art">
fantasai@2304 1584 &lt;----- width / measure -----&gt;
fantasai@1767 1585
fantasai@1767 1586 top side/
fantasai@8130 1587 block-start side
fantasai@1767 1588 +------------------------------+ A
fantasai@1767 1589 left side/ | ---inline direction ---> | right side/ |
fantasai@8130 1590 inline-start side | | | inline-end side |
fantasai@1767 1591 | | block * horizontal * | height/
fantasai@2585 1592 | | direction *writing mode* | extent
fantasai@1767 1593 | V | |
fantasai@1767 1594 +------------------------------+ V
fantasai@1767 1595 bottom side/
fantasai@8130 1596 block-end side
fantasai@1767 1597 </pre>
fantasai@1767 1598 </div>
fantasai@1767 1599 <div class="example">
fantasai@1767 1600 <p>A vertical Japanese block (TTB-RL):</p>
fantasai@1767 1601 <pre class="ascii-art">
fantasai@2585 1602 &lt;----- width / extent ------&gt;
fantasai@1767 1603
fantasai@1767 1604 top side/
fantasai@8130 1605 inline-start side
fantasai@1767 1606 +------------------------------+ A
fantasai@1767 1607 left side/ | &lt;---block direction--- | right side/ |
fantasai@8130 1608 block-end side | | | block-start side |
fantasai@1767 1609 | * vertical * inline| | height/
fantasai@2304 1610 | *writing mode* direction| | measure
fantasai@1767 1611 | V | |
fantasai@1767 1612 +------------------------------+ V
fantasai@1767 1613 bottom side/
fantasai@8130 1614 inline-end side
fantasai@1767 1615 </pre>
fantasai@365 1616 </div>
fantasai@365 1617
fantasai@3923 1618 <h3 id="line-directions">
fantasai@3923 1619 Line-relative Directions</h3>
fantasai@3923 1620
fantasai@3925 1621 <p>The <dfn>line orientation</dfn> determines which side of a line
fantasai@3925 1622 box is the logical “top” (ascender side). It is given by a combination
fantasai@3925 1623 of 'text-orientation' and 'writing-mode'. Usually the line-relative “top”
fantasai@8130 1624 corresponds to the <i>block-start</i> side, but this is not always the case:
fantasai@3925 1625 in Mongolian typesetting (and thus by default in ''vertical-lr'' writing
fantasai@8130 1626 modes), the line-relative “top” corresponds to the <i>block-end</i> side.
fantasai@3925 1627 Hence the need for distinct terminology.
fantasai@3925 1628
fantasai@3925 1629 <div class="figure">
fantasai@3925 1630 <img src="mongolian-lr.jpg" alt="Mongolian mixed with English">
fantasai@3925 1631 <p class="caption">A primarily Mongolian document, such as the one above, is written in
fantasai@3925 1632 vertical lines stacking left to right, but lays its Latin text with
fantasai@3925 1633 the tops of the glyphs towards the right. This makes the text run in
fantasai@3925 1634 the same inline direction as Mongolian (top-to-bottom) and face the
fantasai@3925 1635 same direction it does in other East Asian layouts (which have vertical
fantasai@3925 1636 lines stacking right to left), but the glyphs' tops are facing the
fantasai@3925 1637 bottom of the line stack rather than the top, which in an English
fantasai@3926 1638 paragraph would be upside-down. (See this
fantasai@3926 1639 <a href="diagrams/text-flow-vectors-lr-reverse.svg">Diagram of Mongolian
fantasai@3926 1640 Text Layout</a>.)
fantasai@3925 1641 </div>
fantasai@3925 1642
fantasai@3925 1643 <p>In addition to a line-relative “top” and “bottom” to map things like
fantasai@3925 1644 'vertical-align: top', CSS also needs to refer to a line-relative
fantasai@3925 1645 “left” and “right” in order to map things like ''text-align: left''.
fantasai@3925 1646 Thus there are four <dfn>line-relative directions</dfn>, which are
fantasai@3925 1647 defined relative to the <i>line orientation</i> as follows:
fantasai@3925 1648
fantasai@3925 1649 <dl>
fantasai@3925 1650 <dt><dfn>over</dfn>
fantasai@3925 1651 <dd>Nominally the side that corresponds to the ascender side or “top”
fantasai@3925 1652 side of a line box. (The side overlines are typically drawn on.)
fantasai@3925 1653 <dt><dfn>under</dfn>
fantasai@3925 1654 <dd>Opposite of <i>over</i>: the line-relative “bottom” or descender side.
fantasai@3925 1655 (The side underlines are typically drawn on.)
fantasai@3925 1656 <dt><dfn>line-left</dfn>
fantasai@3925 1657 <dd>Nominally the side from which <abbr title="left-to-right">LTR</abbr>
fantasai@3925 1658 text would start.
fantasai@3925 1659 <dt><dfn>line-right</dfn>
fantasai@3925 1660 <dd>Nominally the side from which <abbr title="right-to-left">RTL</abbr>
fantasai@3925 1661 text would start. (Opposite of <i>line-left</i>.)
fantasai@3925 1662 </dl>
fantasai@3925 1663
fantasai@5653 1664 <p>See the <a href="#logical-to-physical">table below</a> for the exact
fantasai@3925 1665 mappings between physical and line-relative directions.
fantasai@3923 1666
fantasai@3923 1667 <div class="figure">
fantasai@3923 1668 <a href="diagrams/line-orient-up.svg" type="image/svg+xml">
fantasai@3923 1669 <img src="diagrams/line-orient-up.png" class="landscape"
fantasai@3923 1670 alt="Line orientation compass"></a>
fantasai@3923 1671 <p class="caption">Line orientation compass</p>
fantasai@3923 1672 </div>
fantasai@3923 1673
fantasai@3923 1674 <div class="figurepair">
fantasai@3923 1675 <div class="figure">
fantasai@3923 1676 <a href="diagrams/line-orient-right.svg" type="image/svg+xml">
fantasai@3923 1677 <img src="diagrams/line-orient-right.png" class="portrait"
fantasai@3923 1678 alt="Typical orientation in vertical"></a>
fantasai@3923 1679 <p class="caption">Typical orientation in vertical</p>
fantasai@3923 1680 </div>
fantasai@3923 1681
fantasai@3923 1682 <div class="figure">
fantasai@3923 1683 <a href="diagrams/line-orient-left.svg" type="image/svg+xml">
fantasai@3923 1684 <img src="diagrams/line-orient-left.png" class="portrait"
fantasai@3923 1685 alt="Line orientation with ''text-orientation: sideways-left''"></a>
fantasai@3923 1686 <p class="caption">Line orientation with ''text-orientation: sideways-left''</p>
fantasai@3923 1687 </div>
fantasai@3923 1688 </div>
fantasai@3923 1689
fantasai@2304 1690 <h3 id="logical-to-physical">
fantasai@2304 1691 Abstract-to-Physical Mappings</h3>
fantasai@2110 1692
fantasai@2110 1693 <p>The following table summarizes the abstract-to-physical mappings:</p>
fantasai@2110 1694
fantasai@3216 1695 <table class="complex data">
fantasai@3396 1696 <caption>Abstract-Physical Mapping</caption>
fantasai@3215 1697 <colgroup class="header"></colgroup>
fantasai@3216 1698 <colgroup span=10></colgroup>
fantasai@2110 1699 <thead>
fantasai@2110 1700 <tr>
fantasai@2110 1701 <th scope="row">'writing-mode'</th>
fantasai@2110 1702 <th colspan="2">''horizontal-tb''</th>
fantasai@2110 1703 <th colspan="4">''vertical-rl''</th>
fantasai@2110 1704 <th colspan="4">''vertical-lr''</th>
fantasai@2110 1705 </tr>
fantasai@2110 1706 <tr>
fantasai@2110 1707 <th scope="row">'text-orientation'</th>
fantasai@2110 1708 <th colspan="2">&mdash;</th>
fantasai@2955 1709 <th colspan="2">''sideways-left''</th>
fantasai@7004 1710 <th colspan="2"><abbr title="mixed, upright, sideways-right">*right</abbr></th>
fantasai@2955 1711 <th colspan="2">''sideways-left''</th>
fantasai@7004 1712 <th colspan="2"><abbr title="mixed, upright, sideways-right">*right</abbr></th>
fantasai@2110 1713 </tr>
fantasai@2110 1714 <tr>
fantasai@2110 1715 <th scope="row">'direction'</th>
fantasai@2110 1716 <th>''ltr''</th>
fantasai@2110 1717 <th>''rtl''</th>
fantasai@2110 1718 <th>''ltr''</th>
fantasai@2110 1719 <th>''rtl''</th>
fantasai@2110 1720 <th>''ltr''</th>
fantasai@2110 1721 <th>''rtl''</th>
fantasai@2110 1722 <th>''ltr''</th>
fantasai@2110 1723 <th>''rtl''</th>
fantasai@2110 1724 <th>''ltr''</th>
fantasai@2110 1725 <th>''rtl''</th>
fantasai@2110 1726 </tr>
fantasai@2110 1727 </thead>
fantasai@2110 1728 <tbody>
fantasai@2110 1729 <tr>
fantasai@2585 1730 <th scope="row">extent</th>
fantasai@2110 1731 <td colspan="2">height</td>
fantasai@2110 1732 <td colspan="8">width</td>
fantasai@2110 1733 </tr>
fantasai@2110 1734 <tr>
fantasai@2110 1735 <th scope="row">measure</th>
fantasai@2110 1736 <td colspan="2">width</td>
fantasai@2110 1737 <td colspan="8">height</td>
fantasai@2110 1738 </tr>
fantasai@2110 1739 <tr>
fantasai@8130 1740 <th scope="row">block-start</th>
fantasai@2110 1741 <td colspan="2">top</td>
fantasai@2110 1742 <td colspan="4">right</td>
fantasai@2110 1743 <td colspan="4">left</td>
fantasai@2110 1744 </tr>
fantasai@2110 1745 <tr>
fantasai@8130 1746 <th scope="row">block-end</th>
fantasai@2110 1747 <td colspan="2">bottom</td>
fantasai@2110 1748 <td colspan="4">left</td>
fantasai@2110 1749 <td colspan="4">right</td>
fantasai@2110 1750 </tr>
fantasai@2110 1751 <tr>
fantasai@8130 1752 <th scope="row">inline-start</th>
fantasai@2110 1753 <td>left</td>
fantasai@2110 1754 <td>right</td>
fantasai@2110 1755 <td>bottom</td>
fantasai@2110 1756 <td>top</td>
fantasai@2110 1757 <td>top</td>
fantasai@2110 1758 <td>bottom</td>
fantasai@2110 1759 <td>bottom</td>
fantasai@2110 1760 <td>top</td>
fantasai@2110 1761 <td>top</td>
fantasai@2110 1762 <td>bottom</td>
fantasai@2110 1763 </tr>
fantasai@2110 1764 <tr>
fantasai@8130 1765 <th scope="row">inline-end</th>
fantasai@2110 1766 <td>right</td>
fantasai@2110 1767 <td>left</td>
fantasai@2110 1768 <td>top</td>
fantasai@2110 1769 <td>bottom</td>
fantasai@2110 1770 <td>bottom</td>
fantasai@2110 1771 <td>top</td>
fantasai@2110 1772 <td>top</td>
fantasai@2110 1773 <td>bottom</td>
fantasai@2110 1774 <td>bottom</td>
fantasai@2110 1775 <td>top</td>
fantasai@2110 1776 </tr>
fantasai@2110 1777 </tbody>
fantasai@2110 1778 <tbody>
fantasai@2110 1779 <tr>
fantasai@2110 1780 <th scope="row">over</th>
fantasai@2110 1781 <td colspan="2">top</td>
smurakam@2113 1782 <td colspan="2">left</td>
smurakam@2113 1783 <td colspan="2">right</td>
smurakam@2113 1784 <td colspan="2">left</td>
smurakam@2113 1785 <td colspan="2">right</td>
fantasai@2110 1786 </tr>
fantasai@2110 1787 <tr>
fantasai@2110 1788 <th scope="row">under</th>
fantasai@2110 1789 <td colspan="2">bottom</td>
smurakam@2113 1790 <td colspan="2">right</td>
smurakam@2113 1791 <td colspan="2">left</td>
smurakam@2113 1792 <td colspan="2">right</td>
smurakam@2113 1793 <td colspan="2">left</td>
fantasai@2110 1794 </tr>
fantasai@2110 1795 <tr>
fantasai@2110 1796 <th scope="row">line-left</th>
fantasai@2110 1797 <td colspan="2">left</td>
smurakam@2113 1798 <td colspan="2">bottom</td>
smurakam@2113 1799 <td colspan="2">top</td>
smurakam@2113 1800 <td colspan="2">bottom</td>
smurakam@2113 1801 <td colspan="2">top</td>
fantasai@2110 1802 </tr>
fantasai@2110 1803 <tr>
fantasai@2110 1804 <th scope="row">line-right</th>
fantasai@2110 1805 <td colspan="2">right</td>
smurakam@2113 1806 <td colspan="2">top</td>
smurakam@2113 1807 <td colspan="2">bottom</td>
smurakam@2113 1808 <td colspan="2">top</td>
smurakam@2113 1809 <td colspan="2">bottom</td>
fantasai@2110 1810 </tr>
fantasai@2110 1811 </tbody>
fantasai@2110 1812 </table>
fantasai@2110 1813
fantasai@2304 1814 <h2 id="abstract-layout">
fantasai@2304 1815 Abstract Box Layout</h2>
fantasai@2304 1816
fantasai@2304 1817 <h3 id="vertical-layout">
fantasai@2304 1818 Principles of Layout in Vertical Writing Modes</h3>
fantasai@2304 1819
fantasai@2304 1820 <p>CSS box layout in vertical writing modes is analogous to layout in
fantasai@2304 1821 the horizontal writing modes, following the principles outlined below:
fantasai@2304 1822
fantasai@2304 1823 <p>Layout calculation rules (such as those in CSS2.1, Section 10.3)
fantasai@2304 1824 that apply to the horizontal dimension in horizontal writing modes
fantasai@2304 1825 instead apply to the vertical dimension in vertical writing modes.
fantasai@2304 1826 Likewise, layout calculation rules (such as those in CSS2.1, Section 10.6)
fantasai@2304 1827 that apply to the vertical dimension in horizontal writing modes
fantasai@2304 1828 instead apply to the horizontal dimension in vertical writing modes.
fantasai@2304 1829 Thus:
fantasai@2304 1830 <ul>
fantasai@2304 1831 <li><p>Layout rules that refer to the width use the height instead,
fantasai@2304 1832 and vice versa.
fantasai@2304 1833 <li><p>Layout rules that refer to the '*-left' and '*-right' box
fantasai@2304 1834 properties (border, margin, padding) use '*-top' and '*-bottom'
fantasai@3044 1835 instead, and vice versa. Which side of the
fantasai@2304 1836 box the property applies to doesn't change: only which values
fantasai@2304 1837 are inputs to which layout calculations changes. The 'margin-left'
fantasai@2304 1838 property still affects the lefthand margin, for example; however
fantasai@2304 1839 in a ''vertical-rl'' writing mode it takes part in margin collapsing
fantasai@2304 1840 in place of 'margin-bottom'.</p>
fantasai@2304 1841 <li><p>Layout rules that depend on the 'direction' property to choose between
fantasai@2304 1842 left and right (e.g. overflow, overconstraint resolution, the initial
fantasai@2304 1843 value for 'text-align', table column ordering)
fantasai@8130 1844 are abstracted to the <i>start</i> and <i>end</i> sides
fantasai@8130 1845 and applied appropriately.</li>
fantasai@2304 1846 </ul>
fantasai@2304 1847
fantasai@2916 1848 <div class="example">
fantasai@8130 1849 <p>For example, in vertical writing modes,
fantasai@8130 1850 table rows are vertical and table columns are horizontal.
fantasai@8130 1851 In a ''vertical-rl'' ''mixed'' ''rtl'' table,
fantasai@8130 1852 the first column would be on the bottom (the <i>inline-start</i> side),
fantasai@8130 1853 and the first row on the right (the <i>block-start</i> side).
fantasai@8130 1854 The table's 'margin-right' and 'margin-left' would collapse
fantasai@8130 1855 with margins before (on the right) and after (on the left) the table, respectively,
fantasai@8130 1856 and if the table had ''auto'' values for 'margin-top' and 'margin-bottom'
fantasai@8130 1857 it would be centered vertically within its block flow.
fantasai@2916 1858 <div class="figure">
fantasai@2916 1859 <p><a href="diagrams/vertical-table.svg" type="image/svg+xml">
fantasai@7004 1860 <img alt="Diagram of a vertical-rl mixed rtl table in a
fantasai@2916 1861 vertical block formatting context, showing the ordering of rows,
fantasai@2916 1862 cells, and columns as described above."
fantasai@2916 1863 class="example" src="diagrams/vertical-table.png"></a>
fantasai@2916 1864 <p class="caption">Table in ''vertical-rl'' RTL writing mode</p>
fantasai@2916 1865 </div>
fantasai@2916 1866
fantasai@2916 1867 </div>
fantasai@2916 1868
fantasai@2304 1869 <p>For features such as text alignment, floating, and list marker positioning,
fantasai@2304 1870 that primarily reference the left or right sides of the line box or
fantasai@2304 1871 its longitudinal parallels and therefore have no top or bottom equivalent,
fantasai@2304 1872 the <a href="#line-left">line left</a> and <a href="#line-right">line
fantasai@2304 1873 right</a> sides are used as the reference for the left and right sides
fantasai@2304 1874 respectively.
fantasai@2304 1875
fantasai@2304 1876 <p>Likewise for features such as underlining, overlining, and baseline alignment
fantasai@2304 1877 (the unfortunately-named 'vertical-align'), that primarily reference the
fantasai@2304 1878 top or bottom sides of the linebox or its transversal parallels and
fantasai@2304 1879 therefore have no left or right equivalent, the <a href="#over">over</a>
fantasai@2304 1880 and <a href="#under">under</a> sides are used as the reference for the
fantasai@2304 1881 top and bottom sides respectively.
fantasai@2304 1882
fantasai@2304 1883 <p>The details of these mappings are provided below.
fantasai@2304 1884
fantasai@2304 1885 <h3 id="dimension-mapping">
fantasai@2304 1886 Dimensional Mapping</h3>
fantasai@2304 1887
fantasai@2304 1888 <!--
fantasai@2304 1889 <p>Properties that are named in terms of the x and y axes are
fantasai@2304 1890 logical with respect to the block flow direction rather than absolute
fantasai@2304 1891 with respect to the page. Specifically:
fantasai@2304 1892
fantasai@2304 1893 <ul>
fantasai@2304 1894 <li>The ''repeat-x'' keyword of 'background-repeat' tiles in the
fantasai@2304 1895 inline dimension of the element, which is not necessarily the
fantasai@2304 1896 horizontal dimension. [[!CSS21]] [[!CSS3BG]]
fantasai@2304 1897 <li>The ''repeat-y'' keyword of 'background-repeat' tiles in the
kojiishi@2622 1898 block flow dimension of the element, which is not necessarily
kojiishi@2622 1899 the vertical dimension. [[!CSS21]] [[!CSS3BG]]
fantasai@2304 1900 <li>The 'overflow-x' property controls overflow in the inline
fantasai@2304 1901 dimension of the element. [[!CSS3UI]]
fantasai@2304 1902 <li>The 'overflow-y' property controls overflow in the block
fantasai@2304 1903 flow dimension of the element. [[!CSS3UI]]
fantasai@2304 1904 </ul>
fantasai@2304 1905 -->
fantasai@2304 1906
fantasai@2304 1907 <p>Certain properties behave logically as follows:
fantasai@2304 1908 <ul>
fantasai@2304 1909 <li>The first and second values of the 'border-spacing' property
fantasai@2304 1910 represent spacing between columns and rows respectively, not
fantasai@2304 1911 necessarily the horizontal and vertical spacing respectively.
fantasai@2304 1912 [[!CSS21]]
fantasai@2304 1913 <li>The 'line-height' property always refers to the logical
fantasai@2304 1914 height. [[!CSS21]]
fantasai@2304 1915 </ul>
fantasai@2304 1916
fantasai@2304 1917 <p>The height properties ('height', 'min-height', and 'max-height')
fantasai@2304 1918 refer to the physical height, and the width properties ('width',
fantasai@2304 1919 'min-width', and 'max-width') refer to the physical width. However,
fantasai@2304 1920 the rules used to calculate box dimensions and positions are logical.
fantasai@2304 1921
fantasai@2304 1922 <p>For example, the calculation rules in
fantasai@2304 1923 <a href="http://www.w3.org/TR/CSS21/visudet.html#Computing_widths_and_margins">CSS2.1 Section 10.3</a>
fantasai@8130 1924 are used for the inline dimension measurements:
fantasai@8130 1925 they apply to the measure (which could be either the physical width or physical height)
fantasai@8130 1926 and to the <i>inline-start</i> and <i>inline-end</i> margins, padding, and border.
fantasai@2304 1927 Likewise the calculation rules in
fantasai@2304 1928 <a href="http://www.w3.org/TR/CSS21/visudet.html#Computing_heights_and_margins">CSS2.1 Section 10.6</a>
fantasai@6998 1929 are used in the block dimension: they apply to the <i>extent</i> and to
fantasai@8130 1930 the <i>block-start</i> and <i>block-end</i> margins, padding, and border. [[!CSS21]]
fantasai@2304 1931
fantasai@2304 1932 <p>As a corollary, percentages on the margin and padding properties,
fantasai@2304 1933 which are always calculated with respect to the containing block
fantasai@2304 1934 width in CSS2.1, are calculated with respect to the <em>measure</em>
fantasai@2304 1935 of the containing block in CSS3.
fantasai@2304 1936
fantasai@2304 1937 <h3 id="orthogonal-flows">
fantasai@2304 1938 Orthogonal Flows</h3>
fantasai@2304 1939
fantasai@2304 1940 <p>When an element has a different 'writing-mode' from its
fantasai@2304 1941 containing block two cases are possible:
jackalmage@6884 1942
fantasai@2304 1943 <ul>
fantasai@2304 1944 <li>The two writing modes are parallel to each other. (For example,
fantasai@2304 1945 ''vertical-rl'' and ''vertical-lr'').</li>
fantasai@2304 1946 <li>The two writing modes are perpendicular to each other. (For
fantasai@2304 1947 example, ''horizontal-tb'' and ''vertical-rl'').</li>
fantasai@2304 1948 </ul>
fantasai@2304 1949
jackalmage@6884 1950 <p>
jackalmage@6884 1951 When an element has a writing mode that is perpendicular to its containing block
fantasai@8454 1952 it is said to be in, or establish, an <dfn title="establish an orthogonal flow | orthogonal flow">orthogonal flow</dfn>.
jackalmage@6884 1953
jackalmage@6884 1954 <p>
jackalmage@6884 1955 To handle this case, CSS layout calculations are divided into
fantasai@2882 1956 two phases: sizing a box, and positioning the box within its flow.
jackalmage@6884 1957
jackalmage@6884 1958 <ul>
jackalmage@6884 1959 <li>
jackalmage@6884 1960 In the sizing phase—calculating the width and height of the
jackalmage@6884 1961 box—the dimensions of the box and the containing block
jackalmage@6884 1962 are mapped to the measure and extent and calculations are performed
jackalmage@6884 1963 accordingly using the writing mode of the <em>element</em>.
jackalmage@6884 1964 <li>
jackalmage@6884 1965 In the positioning phase—calculating the positioning offsets,
jackalmage@6884 1966 margins, borders, and padding—the dimensions of the box and
jackalmage@6884 1967 its containing block are mapped to the measure and extent and
jackalmage@6884 1968 calculations are performed according to the writing mode of the
jackalmage@6884 1969 <em>containing block</em>.
jackalmage@6884 1970 </ul>
jackalmage@6884 1971
jackalmage@6884 1972 <p>Since ''auto'' margins are resolved consistent with the containing
fantasai@8454 1973 block's writing mode, a box establishing an <i>orthogonal flow</i> can,
fantasai@2882 1974 once sized, be aligned or centered within its containing block just
fantasai@2882 1975 like other block-level elements by using auto margins.
fantasai@2882 1976
jackalmage@6884 1977 <div class='example'>
jackalmage@6884 1978 <p>
jackalmage@6884 1979 For example, if a vertical block is placed inside a horizontal
jackalmage@6884 1980 block, then when calculating the physical height (which is the
jackalmage@6884 1981 measure) of the child block the physical height of the parent
jackalmage@6884 1982 block is used as the child's containing block measure, even
jackalmage@6884 1983 though the physical height is the extent, not the measure, of
jackalmage@6884 1984 the parent block.
jackalmage@6884 1985
jackalmage@6884 1986 <p>
jackalmage@6884 1987 On the other hand,
jackalmage@6884 1988 because the containing block is in a horizontal writing mode,
jackalmage@6884 1989 the vertical margins on the child participate in margin-collapsing,
jackalmage@6884 1990 even though they are in the inline-axis of the child,
jackalmage@6884 1991 and horizontal auto margins will expand to fill the containing block,
jackalmage@6884 1992 even though they are in the block-axis of the child.
jackalmage@6884 1993
jackalmage@6884 1994 <p class='issue'>
jackalmage@6884 1995 Add a picture.
jackalmage@6884 1996 </div>
jackalmage@6884 1997
jackalmage@6889 1998 <p>It is common in CSS for a containing block to have a definite
jackalmage@6889 1999 measure, but not a definite extent. This typically happens in
fantasai@2305 2000 CSS2.1 when a containing block has an ''auto'' height, for
fantasai@2305 2001 example: its width is given by the calculations in
fantasai@2305 2002 <a href="http://www.w3.org/TR/CSS21/visudet.html#blockwidth">10.3.3</a>,
fantasai@2585 2003 but its extent depends on its contents. In such cases the
jackalmage@6889 2004 <i>available measure</i> is defined as the measure of the
jackalmage@6889 2005 containing block; but the <i>available extent</i>, which
fantasai@2882 2006 would otherwise be the extent of the containing block, is
fantasai@2882 2007 infinite.
fantasai@2305 2008
fantasai@8454 2009 <p>Putting a box in an <i>orthogonal flow</i> allows the opposite to happen:
fantasai@8454 2010 for the <i>available extent</i> to be defined, but the <i>available
fantasai@3640 2011 measure</i> to be indefinite. In such cases a percentage of the
fantasai@3640 2012 containing block measure cannot be defined, and inline-axis
fantasai@3640 2013 computations cannot be resolved. In these cases, the initial
fantasai@3642 2014 containing block's size is used as a <i>fallback</i> variable
fantasai@3640 2015 in place of the <i>available measure</i> for calculations that
jackalmage@6889 2016 require a definite <i>available measure</i>.
fantasai@2304 2017
fantasai@2305 2018 <h4 id="orthogonal-auto">
fantasai@2305 2019 Auto-sizing in Orthogonal Flows</h4>
fantasai@2305 2020
fantasai@7004 2021 <p class="issue">
fantasai@7004 2022 This section needs careful review for whether it is a) correct and b) sensible.
fantasai@7004 2023
jackalmage@6889 2024 <p>
jackalmage@6890 2025 If the UA does not support CSS Multi-column Layout [[!CSS3COL]]
jackalmage@6890 2026 and the element is a block container,
jackalmage@6890 2027 when the computed measure of the element establishing an orthogonal flow is ''auto'',
jackalmage@6889 2028 then the used inner measure is calculated as:
jackalmage@6889 2029
jackalmage@6889 2030 <p>
jackalmage@6889 2031 <code>min(<var>max-content</var>, max(<var>min-content</var>, min(<var>fill-available</var>, <var>fill-fallback</var>)))</code>,
jackalmage@6889 2032 where:
jackalmage@6889 2033
jackalmage@6889 2034 <dl>
jackalmage@6889 2035 <dt><var>min-content</var>
jackalmage@6889 2036 <dd>the <a href="http://www.w3.org/TR/css3-sizing/#min-content-measure">min-content measure</a> of the element
jackalmage@6889 2037
jackalmage@6889 2038 <dt><var>max-content</var>
jackalmage@6889 2039 <dd>the <a href="http://www.w3.org/TR/css3-sizing/#max-content-measure">max-content measure</a> of the element
jackalmage@6889 2040
jackalmage@6889 2041 <dt><var>fill-available</var>
jackalmage@6889 2042 <dd>the <a href="http://www.w3.org/TR/css3-sizing/#fill-available-fit">fill-available fit</a> into the element's containing block's size in the element's inline axis
jackalmage@6889 2043
jackalmage@6889 2044 <dt><var>fill-fallback</var>
jackalmage@6889 2045 <dd>the <a href="http://www.w3.org/TR/css3-sizing/#fill-available-fit">fill-available fit</a> into the initial containing block's size in the element's inline axis
jackalmage@6889 2046 </dl>
jackalmage@6889 2047
jackalmage@6889 2048 <p>
jackalmage@6889 2049 See [[!CSS3-SIZING]] for further details.
fantasai@2304 2050
fantasai@2305 2051 <h4 id="orthogonal-multicol">
fantasai@2305 2052 Multi-column Layout in Orthogonal Flows</h4>
fantasai@2305 2053
jackalmage@6890 2054 <p>
jackalmage@6890 2055 If the UA supports CSS Multi-column Layout [[!CSS3COL]]
jackalmage@6890 2056 and the element is a block container or multi-column element,
fantasai@2771 2057 for the case where the element's extent or available extent is
jackalmage@6890 2058 <i>definite</i> but the element's measure is ''auto'':
fantasai@2305 2059
fantasai@2586 2060 <ol>
jackalmage@6890 2061 <li>
jackalmage@6890 2062 If 'column-count' and 'column-width' are both ''auto'',
jackalmage@6890 2063 calculate the used 'column-width' as
jackalmage@6890 2064 the inner measure for ''auto''-sized elements, as defined above.
jackalmage@6890 2065 <li>
jackalmage@6890 2066 If the columns' extent is <i>indefinite</i>,
jackalmage@6890 2067 the <i>fill-available extent</i> of the element is used.
jackalmage@6890 2068 <li>
jackalmage@6890 2069 The used 'column-count' then follows from filling the resulting columns with the element's content.
fantasai@2586 2070 </ol>
fantasai@2886 2071
jackalmage@6890 2072 <p>
jackalmage@6890 2073 The used measure of the resulting multi-column element is then calculated:
jackalmage@6890 2074 if the content neither line-wraps nor fragments within the multi-column element,
jackalmage@6890 2075 then the used measure is the <i>max-content measure</i> of the element's contents;
jackalmage@6890 2076 else it is calculated from the used 'column-width', 'column-count', and 'column-gap'.
jackalmage@6890 2077
jackalmage@6890 2078 <p>
jackalmage@6890 2079 The used extent of the element is either the used column extent
jackalmage@6890 2080 (if multiple columns were used)
jackalmage@6890 2081 or the <i>max-content extent</i> of the content.
fantasai@2586 2082
fantasai@2586 2083 <p class="note">This should behave the same as the auto-sizing algorithm
fantasai@2586 2084 defined in the previous section, except overflowing content, instead of
fantasai@2586 2085 continuing off the side of the containing block, is wrapped into
fantasai@2586 2086 columns in the flow direction of the containing block, thus avoiding
fantasai@2586 2087 T-shaped documents.</p>
fantasai@2305 2088
fantasai@2305 2089 <h4 id="orthogonal-pagination">
jackalmage@6891 2090 Fragmenting Orthogonal Flows</h4>
fantasai@2305 2091
fantasai@2305 2092 <p><em>This section is informative.</em></p>
fantasai@2305 2093
jackalmage@6891 2094 <p>With regards to fragmentation, the rules in CSS2.1 still hold in
jackalmage@6891 2095 vertical writing modes and orthogonal flows: break opportunities
fantasai@2772 2096 do not occur inside line boxes, only between them.
fantasai@2772 2097 UAs that support [[!CSS3COL]] may break in the (potentially zero-width)
fantasai@2772 2098 gap between columns, however.
fantasai@2304 2099
fantasai@2305 2100 <p>Note that if content spills outside the pagination stream
fantasai@2304 2101 established by the root element, the UA is not required to print
fantasai@2304 2102 such content. Authors wishing to mix writing modes with long streams
fantasai@2304 2103 of text are thus encouraged to use CSS columns to keep all content
fantasai@2304 2104 flowing in the document's pagination direction.
fantasai@2305 2105
fantasai@2305 2106 <div class="note">
fantasai@2304 2107 <p>In other words, if your document would require two scrollbars on
fantasai@2304 2108 the screen it probably won't all print. Fix your layout, e.g. by
fantasai@2304 2109 using <a href="http://www.w3.org/TR/css3-multicol/">columns</a> so
fantasai@2304 2110 that it all scrolls (and therefore paginates) in one direction if
fantasai@2304 2111 you want to make sure it'll all print. T-shaped documents tend not
fantasai@2304 2112 to print well.
fantasai@2304 2113 </div>
fantasai@2304 2114
fantasai@2304 2115 <h3 id="logical-direction-layout">
fantasai@2304 2116 Flow-Relative Mappings</h3>
fantasai@2304 2117
fantasai@2304 2118 <p>Flow-relative directions are calculated with respect to
fantasai@2884 2119 the writing mode of the <em>containing block</em> of the
fantasai@2884 2120 element and used to abstract layout rules related to the
fantasai@2884 2121 box properties (margins, borders, padding) and any properties
fantasai@2884 2122 related to positioning the box within its containing block
fantasai@2884 2123 ('float', 'clear', 'top', 'bottom', 'left', 'right')
fantasai@2884 2124 For inline-level elements, the writing mode of the <em>parent
fantasai@2884 2125 element</em> is used instead.
fantasai@2304 2126
fantasai@2884 2127 <p>For example, the margin that is dropped when a box's inline
fantasai@2884 2128 dimension is
fantasai@2884 2129 <a href="http://www.w3.org/TR/CSS21/visudet.html#blockwidth">over-constrained</a>
fantasai@2884 2130 is the end margin as determined by the writing mode of the
fantasai@2884 2131 containing block.
fantasai@2304 2132
fantasai@2304 2133 <p>The <a href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins">margin
fantasai@8130 2134 collapsing rules</a> apply exactly with the <em><i>block-start</i>
fantasai@2304 2135 margin</em> substituted for the top margin and the
fantasai@8130 2136 <em><i>block-end</i> margin</em> substituted for the bottom margin.
fantasai@8130 2137 Similarly the <i>block-start</i> padding and border are substituted
fantasai@8130 2138 for the top padding and border, and the <i>block-end</i> padding and
fantasai@2884 2139 border substituted for the bottom padding and border.
fantasai@8130 2140 Note this means only <i>block-start</i> and <i>block-end</i> margins ever collapse.
fantasai@2304 2141
fantasai@2884 2142 <p>Flow-relative directions are calculated with respect to
fantasai@2884 2143 the writing mode of the element and used to abstract layout
fantasai@2884 2144 related to the element's contents:
fantasai@2304 2145
fantasai@2304 2146 <ul>
fantasai@2304 2147 <li>The initial value of the 'text-align' property
fantasai@8130 2148 aligns to the <i>start</i> edge of the line box.
fantasai@8130 2149 <li>The 'text-indent' property indents from the <i>start</i>
fantasai@2304 2150 edge of the line box.
fantasai@8130 2151 <li>For tables, the ordering of columns begins on the <i>inline-start</i>
fantasai@2888 2152 side of the table, and the ordering of rows begins on the
fantasai@8130 2153 <i>block-start</i> side of the table.
fantasai@2304 2154 </ul>
fantasai@2304 2155
fantasai@2304 2156 <h3 id="line-mappings">
fantasai@2304 2157 Line-Relative Mappings</h3>
fantasai@2304 2158
fantasai@2304 2159 <p>The <dfn>line-relative directions</dfn> are
fantasai@2304 2160 <a href="#over">over</a>,
fantasai@2304 2161 <a href="#under">under</a>,
fantasai@2304 2162 <a href="#line-left">line-left</a>, and
fantasai@2304 2163 <a href="#line-right">line-right</a>. In an
fantasai@2304 2164 <abbr title="left-to-right">LTR</abbr>
fantasai@2304 2165 ''horizontal-tb'' writing mode, they correspond to the
fantasai@2304 2166 top, bottom, left, and right directions, respectively.
fantasai@2304 2167
fantasai@2304 2168 <p>The line-right and line-left directions are calculated
fantasai@2304 2169 with respect to the writing mode of the element and used
fantasai@2304 2170 to interpret the ''left'' and ''right'' values of the
fantasai@2304 2171 following properties:
fantasai@2304 2172 <ul>
fantasai@2304 2173 <li>the 'text-align' property [[!CSS21]]
fantasai@2304 2174 </ul>
fantasai@2304 2175
fantasai@2304 2176 <p>The line-right and line-left directions are calculated
fantasai@2304 2177 with respect to the writing mode of the <em>containing
fantasai@2304 2178 block</em> of the element and used to interpret the ''left''
fantasai@2304 2179 and ''right'' values of the following properties:
fantasai@2304 2180 <ul>
fantasai@2304 2181 <li>the 'float' property [[!CSS21]]
fantasai@2304 2182 <li>the 'clear' property [[!CSS21]]
fantasai@2304 2183 </ul>
fantasai@2304 2184
fantasai@2304 2185 <p>The over and under directions are calculated with respect to
fantasai@2304 2186 the writing mode of the element and used to define the
fantasai@2304 2187 interpretation of the "top" (over edge) and "bottom" (under
fantasai@2304 2188 edge) of the line box as follows:
fantasai@2304 2189
fantasai@2304 2190 <ul>
fantasai@2304 2191 <li>For the 'vertical-align' property, the "top" of the
fantasai@2304 2192 line box is the over edge; the "bottom" of the line box
fantasai@2304 2193 is the under edge. Positive length and percentage values
fantasai@2304 2194 shift the baseline towards the over edge. [[!CSS21]]
fantasai@2304 2195 <li>For the 'text-decoration' property, the underline is
fantasai@2304 2196 drawn on the under side of the text; the overline is
fantasai@2304 2197 drawn on the over side of the text. [[!CSS21]]
fantasai@2304 2198 <span class="note">Note that the CSS Text Module defines
fantasai@2304 2199 this in more detail and provides additional controls for
fantasai@2304 2200 controlling the position of underlines and overlines.
fantasai@2304 2201 [[CSS3TEXT]]</span>
fantasai@2304 2202 </ul>
fantasai@2304 2203
fantasai@2304 2204 <h3 id="physical-only">
fantasai@2304 2205 Purely Physical Mappings</h3>
fantasai@2103 2206
fantasai@2103 2207 <p>The following values are purely physical in their definitions
fantasai@2103 2208 and do not respond to changes in writing mode:
fantasai@2103 2209
fantasai@2103 2210 <ul>
fantasai@2103 2211 <li>the ''rect()'' notation of the 'clip' property [[!CSS21]]
fantasai@2885 2212 <li>the background properties [[!CSS21]] [[!CSS3BG]]
fantasai@2885 2213 <li>the border-image properties [[!CSS3BG]]
fantasai@2103 2214 <li>the offsets of the 'box-shadow' and 'text-shadow' properties
fantasai@2103 2215 </ul>
fantasai@2103 2216
fantasai@2304 2217 <h3 id="caption-side">
fantasai@2888 2218 Table Caption Mappings: the 'caption-side' keywords</h3>
fantasai@2888 2219
fantasai@2888 2220 <table class="propdef">
fantasai@2888 2221 <tbody>
fantasai@2888 2222 <tr>
fantasai@2888 2223 <th>Property:</th>
fantasai@2888 2224 <td>'caption-side'</td>
fantasai@2888 2225 </tr>
fantasai@2888 2226 <tr>
fantasai@2888 2227 <th>New Values:</th>
fantasai@8446 2228 <td>''block-start'' | ''block-end''</td>
fantasai@2888 2229 </tr>
fantasai@2888 2230 <tr>
fantasai@2888 2231 <th>Initial:</th>
fantasai@8161 2232 <td>start</td>
fantasai@2888 2233 </tr>
fantasai@2888 2234 <tr>
fantasai@2888 2235 <th>Applies to:</th>
fantasai@2888 2236 <td>same as CSS2.1</td>
fantasai@2888 2237 </tr>
fantasai@2888 2238 <tr>
fantasai@2888 2239 <th>Inherited:</th>
fantasai@2888 2240 <td>same as CSS2.1</td>
fantasai@2888 2241 </tr>
fantasai@2888 2242 <tr>
fantasai@2888 2243 <th>Percentages:</th>
fantasai@2888 2244 <td>same as CSS2.1</td>
fantasai@2888 2245 </tr>
fantasai@2888 2246 <tr>
fantasai@2888 2247 <th>Media:</th>
fantasai@2888 2248 <td>same as CSS2.1</td>
fantasai@2888 2249 </tr>
fantasai@2888 2250 <tr>
fantasai@2888 2251 <th>Computed&#160;value:</th>
fantasai@2888 2252 <td>specified value</td>
fantasai@2888 2253 </tr>
fantasai@2888 2254 </tbody>
fantasai@2888 2255 </table>
fantasai@2888 2256
fantasai@2103 2257 <p>This module introduces two new values to the 'caption-side' property:
fantasai@8446 2258 ''block-start'' and ''block-end'',
fantasai@8446 2259 which position the caption before and after the table box, respectively.
fantasai@8446 2260 For tables with ''horizontal-tb'' writing mode,
fantasai@8446 2261 they are equivalent to the existing ''top'' and ''bottom'' values, respectively. [[!CSS21]]
fantasai@8446 2262
fantasai@8446 2263 <p class='note'>For implementations that support the ''top-outside''
fantasai@8446 2264 and ''bottom-outside'' model, corresponding ''start-outside'' and
fantasai@8446 2265 ''end-outside'' are similarly introduced.
fantasai@2888 2266
fantasai@2304 2267 <p>Implementations that support the ''top'' and ''bottom'' values
fantasai@2304 2268 of the 'caption-side' property but do not support side captions
fantasai@2304 2269 (i.e. ''left'' and ''right'' captions in horizontal writing modes)
fantasai@8446 2270 must treat both ''top'' and ''bottom'' as ''block-start'',
fantasai@8446 2271 when the table is in a vertical writing mode.
fantasai@2103 2272
fantasai@8130 2273 <p>For implementations that do support side captions
fantasai@8130 2274 (i.e. the ''left'' and ''right'' values from the obsolete CSS&nbsp;2.0 specification [[CSS2]]),
fantasai@8161 2275 this module also introduces the ''inline-start'' and ''inline-end'' values,
fantasai@8130 2276 which behave similarly and which position the
fantasai@8130 2277 caption on the <i>inline-start</i> and <i>inline-end</i> sides of the table box,
fantasai@8130 2278 calculated with respect to the writing mode of the table element.
fantasai@8130 2279 For such implementations, the ''top'' and ''bottom'' values must place the
fantasai@2103 2280 caption on the top and bottom sides of the table box, respectively.
fantasai@2888 2281
fantasai@2888 2282 <p class="note">The CSS2.0 side caption model had some
fantasai@2888 2283 <a href="http://lists.w3.org/Archives/Public/www-style/2002Dec/0142.html">problems</a>
fantasai@2888 2284 and will likely have a different definition in CSS3.</p>
fantasai@2888 2285
fantasai@2172 2286 <!--
fantasai@2107 2287 <h3 id="html-attributes">HTML Attributes</h3>
fantasai@2103 2288
fantasai@2103 2289 <p>This section defines the mapping of HTML presentational attributes
fantasai@2103 2290 in CSS. This section is normative for user agents supporting HTML
bert@2187 2291 in addition to the 'writing-mode' property. [[!HTML40]] [[!HTML5]]
fantasai@2103 2292
fantasai@2103 2293 <h4 id="width-height-attributes">The <code>width</code> and <code>height</code> attributes</h4>
fantasai@2103 2294
fantasai@2103 2295 <p>The HTML <code>width</code> and <code>height</code> attributes refer
fantasai@2103 2296 to the physical width and height for elements that that are replaced,
fantasai@2103 2297 i.e.
fantasai@2103 2298 <code>&lt;applet&gt;</code>,
fantasai@2103 2299 <code>&lt;embed&gt;</code>,
fantasai@2103 2300 <code>&lt;iframe&gt;</code>,
fantasai@2103 2301 <code>&lt;img&gt;</code>,
fantasai@2103 2302 <code>&lt;object&gt;</code>,
fantasai@2103 2303 <code>&lt;canvas&gt;</code>,
fantasai@2103 2304 and
fantasai@2103 2305 <code>&lt;video&gt;</code>
fantasai@2103 2306
fantasai@2103 2307 <p>Form elements elements contain text, therefore their contents should be
fantasai@2103 2308 affected by writing mode, in which case these attributes refer to the
fantasai@2103 2309 <em>logical</em> width and height. The UA may, however, choose not
fantasai@2103 2310 to rotate nor flip these elements in vertical writing modes if it is not
fantasai@2103 2311 capable, and in that case, these attributes remain physical.</p>
fantasai@2103 2312 <p class="issue">when not to rotate form elements/MathML,
fantasai@2103 2313 should treat them as images (always upright)
fantasai@2103 2314 or to force writing-mode to always calculate to horizontal-tb?</p>
fantasai@2103 2315
fantasai@2103 2316 <p>On table-related elements (<code>&lt;table&gt;</code>, <code>&lt;colgroup&gt;</code>,
fantasai@2103 2317 <code>&lt;col&gt;</code>, <code>&lt;tr&gt;</code>, <code>&lt;th&gt;</code>,
fantasai@2103 2318 <code>&lt;td&gt;</code>) the <code>width</code> and <code>height</code>
fantasai@2103 2319 attributes are always logical.
fantasai@2103 2320
fantasai@2103 2321 <p>The <code>size</code> attribute of the <code>&lt;hr&gt;</code> element
fantasai@2103 2322 is also logical (refers to the logical height).
fantasai@2103 2323
fantasai@2103 2324 <h4 id="alignment-attributes">Alignment, Float and Clear Attributes</h4>
fantasai@2103 2325
fantasai@2103 2326 <p>The following attributes behave the same way as their corresponding
fantasai@2103 2327 CSS properties:</p>
fantasai@2103 2328
fantasai@2103 2329 <ul>
fantasai@2103 2330 <li><code>align</code> as 'float' or 'text-align'</li>
fantasai@2103 2331 <li><code>clear</code> as 'clear'</li>
fantasai@2103 2332 <li><code>valign</code> as 'vertical-align'</li>
fantasai@2103 2333 </ul>
fantasai@2103 2334
fantasai@2103 2335 <h4 id="spacing-attributes">Spacing Attributes</h4>
fantasai@2103 2336
fantasai@2103 2337 <p>The following attributes are logical and, as margins, are logical
fantasai@2103 2338 with respect to the writing mode of the <em>parent</em> element.</p>
fantasai@2103 2339
fantasai@2103 2340 <ul>
fantasai@8130 2341 <li><code>hspace</code> as inline-start and inline-end margins</li>
fantasai@8130 2342 <li><code>vspace</code> as block-start and block-end margins</li>
fantasai@2103 2343 <li>marginwidth</li>
fantasai@2103 2344 <li>marginheight</li>
fantasai@2103 2345 </ul>
fantasai@2172 2346 -->
fantasai@1767 2347
fantasai@2778 2348 <h2 id="page-direction">
fantasai@2778 2349 Page Flow: the page progression direction</h2>
fantasai@2778 2350
fantasai@2778 2351 <p>In paged media CSS2.1 classifies all pages as either left or right pages.
fantasai@2778 2352 The page progression direction, which determines whether the left or right
fantasai@2778 2353 page in a spread is first in the flow and whether the first page is by
fantasai@2778 2354 default a left or right page, depends on the writing direction as follows:
fantasai@2778 2355
fantasai@2778 2356 <ul>
fantasai@2778 2357 <li>The page progression is right-to-left if the root element's
fantasai@2778 2358 'writing-mode' is ''vertical-rl'' or if the root element's 'writing-mode'
fantasai@2778 2359 is ''horizontal-tb'' and its 'direction' is ''rtl''.
fantasai@2778 2360 <li>The page progression is left-to-right if the root element's
fantasai@2778 2361 'writing-mode' is ''vertical-lr'' or if the root element's 'writing-mode'
fantasai@2778 2362 is ''horizontal-tb'' and its 'direction' is ''ltr''.
fantasai@2778 2363 </ul>
fantasai@2778 2364
fantasai@2778 2365 <p>(Unless otherwise overridden, the first page of a document begins on the
fantasai@2778 2366 second half of a spread, e.g. on the right page in a left-to-right page
fantasai@2778 2367 progression.)
fantasai@2778 2368
fantasai@2778 2369 <h2 id="text-combine">
fantasai@3385 2370 Glyph Composition</h2>
fantasai@3385 2371
fantasai@3385 2372 <h3 id="text-combine-horizontal">
fantasai@4220 2373 Horizontal-in-Vertical Composition: the 'text-combine-horizontal' property</h3>
fantasai@2180 2374
fantasai@2180 2375 <table class="propdef">
fantasai@2180 2376 <tbody>
fantasai@2180 2377 <tr>
fantasai@2180 2378 <th>Name:</th>
fantasai@2959 2379 <td><dfn>text-combine-horizontal</dfn></td>
fantasai@2180 2380 </tr>
fantasai@2180 2381 <tr>
fantasai@5315 2382 <th><a href="#values">Value</a>:</th>
kojiishi@7000 2383 <td>none | all
kojiishi@7378 2384 | [ digits &lt;integer>? ]
kojiishi@7000 2385 <!--
kojiishi@7000 2386 | [ [ numeric &lt;integer> | digits &lt;integer> ]
fantasai@3202 2387 || [ alpha &lt;integer> | latin &lt;integer> ]
fantasai@3202 2388 || alphanumeric &lt;integer> ]
kojiishi@7000 2389 -->
fantasai@2180 2390 </tr>
fantasai@2180 2391 <tr>
fantasai@2180 2392 <th>Initial:</th>
fantasai@2180 2393 <td>none</td>
fantasai@2180 2394 </tr>
fantasai@2180 2395 <tr>
fantasai@2180 2396 <th>Applies to:</th>
fantasai@2180 2397 <td>non-replaced inline elements</td>
fantasai@2180 2398 </tr>
fantasai@2180 2399 <tr>
fantasai@2180 2400 <th>Inherited:</th>
fantasai@8670 2401 <td><a href="http://lists.w3.org/Archives/Public/www-style/2013Jul/0154.html" class="issue">???</a></td>
fantasai@2180 2402 </tr>
fantasai@2180 2403 <tr>
fantasai@2180 2404 <th>Percentages:</th>
fantasai@2180 2405 <td>N/A</td>
fantasai@2180 2406 </tr>
fantasai@2180 2407 <tr>
fantasai@2180 2408 <th>Media:</th>
fantasai@2180 2409 <td>visual</td>
fantasai@2180 2410 </tr>
fantasai@2180 2411 <tr>
fantasai@2180 2412 <th>Computed&#160;value:</th>
fantasai@2180 2413 <td>specified value</td>
fantasai@2180 2414 </tr>
fantasai@2180 2415 </tbody>
fantasai@2180 2416 </table>
fantasai@2180 2417
fantasai@2180 2418 <p>This property allows the combination of multiple characters into the
fantasai@3015 2419 space of a single character. This property only has an effect
fantasai@2995 2420 in vertical writing modes. Values have the following meanings:</p>
fantasai@2180 2421
fantasai@2180 2422 <dl>
smurakam@2968 2423 <dt><dfn title="text-combine-horizontal:none">none</dfn>
fantasai@2180 2424 <dd>No special processing.</dd>
smurakam@2968 2425 <dt><dfn title="text-combine-horizontal:all">all</dfn>
fantasai@8671 2426 <dd>In vertical writing modes,
fantasai@8671 2427 attempt to display the text contents of the element horizontally within the vertical line box.
fantasai@8671 2428 If the contents are wider than 1em, the UA must fit the contents within 1em, see below.
fantasai@8671 2429 The resulting composition is treated as a single glyph for the purposes
fantasai@3003 2430 of layout and decoration.
fantasai@3363 2431 If the content contains any element boundaries this is treated as
fantasai@3391 2432 ''text-combine-horizontal: none'' on the element and any descendants.
kojiishi@7000 2433 <!--
fantasai@5568 2434 <dt><dfn title="text-combine-horizontal:numeric">numeric</dfn>
fantasai@5568 2435 <dd>Within the element, each sequence of consecutive horizontal numbers
fantasai@3202 2436 that has as many or fewer characters than the integer given is treated
fantasai@3202 2437 as if it were in an anonymous inline box with
fantasai@3202 2438 ''text-combine-horizontal: all''.
fantasai@5568 2439 For this property, a <dfn>horizontal number</dfn> is any character
fantasai@3321 2440 belonging to a Number category (N*) that does not belong to a
fantasai@3015 2441 <a href="#script-orientations">vertical script</a>.
kojiishi@7378 2442 -->
fantasai@8670 2443 <dt><dfn title="text-combine-horizontal:digits">digits <var>&lt;integer></var>?</dfn>
fantasai@8670 2444 <dd>Within the element, each maximal sequence of consecutive ASCII digits (U+0030&ndash;U+0039)
fantasai@3202 2445 that has as many or fewer characters than the integer given is treated
fantasai@3202 2446 as if it were in an anonymous inline box with
fantasai@3202 2447 ''text-combine-horizontal: all''.
kojiishi@7378 2448 When the integer is omitted, 2 is used.
fantasai@8670 2449 Integers outside the range 1-4 are invalid.
kojiishi@7378 2450 <!--
smurakam@2968 2451 <dt><dfn title="text-combine-horizontal:alpha">alpha</dfn>
fantasai@2959 2452 <dd>Within the element, each sequence of consecutive horizontal letters
fantasai@3202 2453 that has as many or fewer characters than the integer given is treated
fantasai@3202 2454 as if it were in an anonymous inline box with
fantasai@3202 2455 ''text-combine-horizontal: all''.
fantasai@4220 2456 For this property, a <dfn>horizontal letter</dfn> is any character belonging
fantasai@3321 2457 to a Letter category (L*) that does not belong to a
fantasai@3015 2458 <a href="#script-orientations">vertical script</a>.
fantasai@3015 2459 <dt><dfn title="text-combine-horizontal:latin">latin</dfn>
fantasai@3015 2460 <dd>Within the element, each sequence of Latin letters
fantasai@3202 2461 that has as many or fewer characters than the integer given is treated
fantasai@3202 2462 as if it were in an anonymous inline box with
fantasai@3202 2463 ''text-combine-horizontal: all''.
fantasai@3321 2464 For this property, a <dfn>Latin letter</dfn> is any character belonging to
fantasai@3015 2465 a Letter category (L*) that also belongs to the Latin script.
fantasai@5568 2466 <p class="issue">This definition could replace ''alpha'' as a simplification.
fantasai@5568 2467 However, it wouldn't work for greek or mixtures of greek and latin (e.g. &mu;m).
smurakam@2968 2468 <dt><dfn title="text-combine-horizontal:alphanumeric">alphanumeric</dfn>
smurakam@2968 2469 <dd>Within the element, each sequence of consecutive horizontal digits and/or
fantasai@3202 2470 letters that has as many or fewer characters than the integer given is treated
fantasai@3202 2471 as if it were in an anonymous inline box with
fantasai@3202 2472 ''text-combine-horizontal: all''.
kojiishi@7000 2473 -->
fantasai@2180 2474 </dl>
fantasai@2180 2475
fantasai@5570 2476 <div class="example">
fantasai@5570 2477 <p>In East Asian documents, the ''text-combine-horizontal'' effect is often
fantasai@5570 2478 used to display Latin-based strings such as components of a date or
fantasai@5570 2479 letters of an initialism, always in a horizontal writing mode
fantasai@5570 2480 regardless of the writing mode of the line:</p>
fantasai@5570 2481
fantasai@5570 2482 <div class="figure">
fantasai@5570 2483 <p><img alt="Diagram of tate-chu-yoko, showing the two digits of a date
fantasai@5570 2484 set halfwidth side-by-side in a vertical column of text"
fantasai@5570 2485 class="example" src="tate-chu-yoko.png">
fantasai@5570 2486 <p class="caption">Example of horizontal-in-vertical <i lang="ja">tate-chu-yoko</i></p>
fantasai@5570 2487 </div>
fantasai@5570 2488
fantasai@5570 2489 <p>The figure is the result of the rules</p>
fantasai@5570 2490 <pre>
kojiishi@7378 2491 <!-- -->date { text-combine-horizontal: digits 2; }
fantasai@5570 2492 </pre>
fantasai@5570 2493 <p>and the following markup:</p>
fantasai@5570 2494 <pre>
kojiishi@7378 2495 <!-- -->&lt;date&gt;&#x5E73;&#x6210;20&#x5E74;4&#x6708;16&#x65E5;&#x306B;&lt;/date&gt;
fantasai@5570 2496 </pre>
fantasai@5570 2497
fantasai@5570 2498 <p>In Japanese, this effect is known as <i lang="ja">tate-chu-yoko</i>.
fantasai@5570 2499 </div>
kojiishi@7378 2500
fantasai@5570 2501 <div class="example">
fantasai@5570 2502 <p>The following example shows that applying ''text-combine-horizontal: digits 2''
fantasai@5570 2503 to an entire document, rather than to a segment with a known type of
fantasai@5570 2504 numeric content, can have unintended consequences:
fantasai@5570 2505 <pre>&lt;p>あれは10,000円ですよ!&lt;/p></pre>
fantasai@5570 2506 <div class="figure">
fantasai@5570 2507 <p><img alt="Rendering of the above markup with 'text-combine-horizontal: digits':
fantasai@5570 2508 the first two digits of the number are rendered as tate-chu-yoko
fantasai@5570 2509 while the rest of the number is rendered sideways."
fantasai@5570 2510 class="example" src="bad-tate-chu-yoko.png">
fantasai@5570 2511 <p class="caption">Example of mis-applied <i lang="ja">tate-chu-yoko</i></p>
fantasai@5570 2512 </div>
fantasai@5570 2513 </div>
kojiishi@7378 2514
fantasai@8671 2515 <p>In order to preserve typographic color when compressing the text to 1em,
fantasai@8671 2516 when the combined text consists of more than one <i>character</i>,
fantasai@8678 2517 then any full-width <i>characters</i> must first be converted to their non-full-width equivalents
fantasai@8678 2518 by reversing the algorithm defined for ''text-transform: full-width'' in [[!CSS3-TEXT]].
fantasai@8671 2519 Also, a 'font-variant' value of ''full-width'' must be ignored in such cases:
fantasai@8671 2520 whether applied via ''@font-face'' descriptor or property declaration,
fantasai@8671 2521 within the combined text this value does not not cause the UA to enable that font feature. [[!CSS3-FONTS]]
kojiishi@7002 2522
fantasai@5571 2523 <div class="example">
fantasai@5571 2524 <p>For example, an author might apply both 'text-transform' and 'text-combine-horizontal'
fantasai@5571 2525 to a date set in vertical text.
fantasai@5571 2526 <pre>date { text-combine-horizontal: digits 2; text-transform: full-width; }</pre>
fantasai@5571 2527 <p>Suppose this style rule is applied to a date such as.
fantasai@5571 2528 <pre>&lt;date>2010年2月23日&lt;/date></pre>
fantasai@8671 2529 <p>The "2010" is too long to be combined (4 digits), but the "2" and "23" will be affected.
fantasai@5571 2530 Since "23" is more than one character, it will not be affected by ''text-transform: full-width''.
fantasai@5571 2531 However since the "2" is only one character, it will be transformed to a fullwidth "2".
fantasai@5571 2532 Since the "2010" was not combined, its digits, too, will be transformed to fullwidth "2010";
fantasai@5571 2533 and being fullwidth, they will be typeset upright, giving the following result:
fantasai@5571 2534 <pre style="text-align: center">
kojiishi@7378 2535 <!-- -->2
kojiishi@7378 2536 <!-- -->0
kojiishi@7378 2537 <!-- -->1
kojiishi@7378 2538 <!-- -->0
kojiishi@7378 2539 <!-- -->年
kojiishi@7378 2540 <!-- -->2
kojiishi@7378 2541 <!-- -->月
kojiishi@7378 2542 <!-- -->23
kojiishi@7378 2543 <!-- -->日</pre>
fantasai@5571 2544 </div>
kojiishi@7378 2545
fantasai@8671 2546 <p>When combining text as for ''text-combine-horizontal: all'',
fantasai@8671 2547 the glyphs of the combined text are composed horizontally
fantasai@8671 2548 (ignoring 'letter-spacing' and any forced line breaks, but using the specified font settings),
fantasai@8671 2549 similar to the contents of an inline-box with a horizontal writing mode and a line-height of 1em.
fantasai@8671 2550 The effective size of the composition is assumed to be 1em square;
fantasai@8671 2551 anything outside the square is not measured for layout purposes.
fantasai@8671 2552 The UA should center the glyphs horizontally and vertically within the measured 1em square.
fantasai@8671 2553 The baseline of the resulting composition must be chosen such that the square is centered
fantasai@8671 2554 between the text-over and text-under baselines of its parent inline box prior to any baseline alignment shift ('vertical-align').
fantasai@8671 2555 For bidi reordering, the composition is treated the same as a character with ''text-orientation: upright''.
fantasai@8671 2556 For line breaking before and after the composition, it is treated as a regular inline with its actual contents.
fantasai@8671 2557 For other text layout purposes,
fantasai@8671 2558 e.g. emphasis marks, text-decoration, spacing,
fantasai@8671 2559 etc. the resulting composition is treated as a single glyph
fantasai@8671 2560 representing the Object Replacement Character U+FFFC.
fantasai@8671 2561
fantasai@8671 2562 <p>The UA must ensure that the combined advance width of the composition
fantasai@8671 2563 fits within 1em by compressing the combined text if necessary.
fantasai@8671 2564 (This does not necessarily mean that the glyphs will fit within 1em,
fantasai@8671 2565 as some glyphs are designed to draw outside their geometric boundaries.)
fantasai@8705 2566 OpenType implementations <em>must</em> use width-specific variants
fantasai@8705 2567 (<code>hwid<code>/<code>twid</code>/<code>qwid</code>)
fantasai@8705 2568 to compress text
fantasai@8705 2569 in cases where those variants are available for all <i>characters</i> in the composition.
fantasai@8705 2570 Otherwise, the UA may use any means to compress the text,
fantasai@8705 2571 including substituting half-width, third-width, and/or quarter-width glyphs provided by the font,
fantasai@8705 2572 using other font features designed to compress text horizontally,
fantasai@8705 2573 scaling the text geometrically,
fantasai@8705 2574 or any combination thereof.
fantasai@8671 2575
fantasai@8671 2576 <div class="example">
fantasai@8671 2577 <p>For example, a simple OpenType-based implementation might compress the text as follows:
fantasai@8671 2578 <ol>
fantasai@8671 2579 <li>Enable 1/<var>n</var>-width glyphs for combined text of <var>n</var> <i>characters</i>.
fantasai@8671 2580 (I.e. Use OpenType <code>hwid</code> for 2 <i>characters</i>, <code>twid</code> for 3 <i>characters</i>, etc.)
fantasai@8671 2581 Note that the number of <i>characters</i> &ne; number of Unicode codepoints!
fantasai@8671 2582 <li>Horizontally scale the result to 1em if it is not yet 1em or narrower.
fantasai@8671 2583 </ol>
fantasai@8671 2584 <p>A more sophisticated OpenType implementation might compose the text
fantasai@8671 2585 first with normal (proportional-width) glyphs to see if that fits,
fantasai@8671 2586 then substitute in half-width or third-width forms as available and necessary,
fantasai@8671 2587 possibly adjusting its approach or combining it with scaling operations
fantasai@8671 2588 depending on the available glyph substitutions.
fantasai@8671 2589 </div>
fantasai@8671 2590
fantasai@8671 2591 <p>In some fonts, the ideographic glyphs are given a compressed design
fantasai@8671 2592 such that they are 1em wide but shorter than 1em tall.
fantasai@8671 2593 To accommodate such fonts, the UA may vertically scale the the composition
fantasai@8671 2594 to match the advance height of 水 U+6C34.
fantasai@8671 2595 <!-- 水 U+6C34 was chosen because it is a very basic character common to
fantasai@8671 2596 all Han-based scripts, so would have to appear in any usable ideographic
fantasai@8671 2597 font; and its shape is very full in both dimensions, so it would be
fantasai@8671 2598 unlikely to be shortened in a proportional font -->
fantasai@8671 2599
kojiishi@7001 2600 <!--
fantasai@3396 2601 <h3 id="text-combine-mode">
fantasai@4220 2602 Horizontal-in-Vertical Glyph Scaling: the 'text-combine-mode' property</h3>
fantasai@3385 2603
fantasai@3385 2604 <table class="propdef">
fantasai@3385 2605 <tbody>
fantasai@3385 2606 <tr>
fantasai@3385 2607 <th>Name:
fantasai@3385 2608 <td><dfn>text-combine-mode</dfn>
fantasai@3385 2609 </tr>
fantasai@3385 2610 <tr>
fantasai@5315 2611 <th><a href="#values">Value</a>:
fantasai@3385 2612 <td>auto | compress | [ no-compress || use-glyphs ]
fantasai@3385 2613 </tr>
fantasai@3385 2614 <tr>
fantasai@3385 2615 <th>Initial:
fantasai@3391 2616 <td>auto
fantasai@3385 2617 </tr>
fantasai@3385 2618 <tr>
fantasai@3385 2619 <th>Applies to:
fantasai@3385 2620 <td>non-replaced inline elements
fantasai@3385 2621 </tr>
fantasai@3385 2622 <tr>
fantasai@3385 2623 <th>Inherited:
fantasai@3385 2624 <td>yes
fantasai@3385 2625 </tr>
fantasai@3385 2626 <tr>
fantasai@3385 2627 <th>Percentages:
fantasai@3385 2628 <td>N/A
fantasai@3385 2629 </tr>
fantasai@3385 2630 <tr>
fantasai@3385 2631 <th>Media:
fantasai@3385 2632 <td>visual
fantasai@3385 2633 </tr>
fantasai@3385 2634 <tr>
fantasai@3385 2635 <th>Computed&#160;value:
fantasai@3385 2636 <td>specified value
fantasai@3385 2637 </tr>
fantasai@3385 2638 </tbody>
fantasai@3385 2639 </table>
fantasai@3385 2640
fantasai@3385 2641 <p>This property controls how multiple characters are combined into the
fantasai@3385 2642 space of a single character when specified to do so via
fantasai@3385 2643 'text-combine-horizontal'. Values have the following meanings:</p>
fantasai@3385 2644
fantasai@3385 2645 <dl>
fantasai@3385 2646 <dt><dfn title="text-combine-mode:auto">auto</dfn>
fantasai@3385 2647 <dd>If the contents are wider than 1em, the UA must attempt to fit the
fantasai@3385 2648 contents within 1em, but may use any method to do so.
fantasai@3385 2649 <dt><dfn title="text-combine-mode:compress">compress</dfn>
fantasai@3385 2650 <dd>Compress the composition (horizontally) as a whole until it fits within 1em.
fantasai@3385 2651 Do not substitute alternate-width glyphs.
fantasai@3385 2652 <dt><dfn title="text-combine-mode:use-glyphs">use-glyphs</dfn>
fantasai@3385 2653 <dd>Attempt to substitute narrower glyphs as necessary to make the
fantasai@3385 2654 composition fit within 1em:
fantasai@3385 2655 <ul>
fantasai@3385 2656 <li>a two-character composition uses 1/2-em or proportional glyphs
fantasai@3385 2657 <li>a three-character composition uses 1/3-em glyphs (if the font
fantasai@3385 2658 supports this feature, else fall back to 1/2-em or proportional glyphs)
fantasai@3385 2659 <li>etc.
fantasai@3385 2660 </ul>
fantasai@3385 2661 <p>Since even fonts that have fractional-width glyphs available do
fantasai@3385 2662 not have such glyphs for all characters, the UA must ensure the
fantasai@3385 2663 expected advance width for ''use-glyphs'' by either compressing or
fantasai@3385 2664 padding (equally on both sides) each glyph individually if it does
fantasai@3385 2665 not match the required advance width. (This step does not apply if
fantasai@3385 2666 ''no-compress'' is specified.)
fantasai@3385 2667 <dt><dfn title="text-combine-mode:no-compress">no-compress</dfn>
fantasai@3385 2668 <dd>Do not compress the composition or perform any glyph substitution
fantasai@3385 2669 in order to make the composition fit within 1em.
fantasai@3385 2670 When combined with ''use-glyphs'', however, this indicates to perform
fantasai@3385 2671 glyph substitution if possible per ''use-glyphs'' but not to compress
fantasai@3385 2672 the glyphs if they do not fit the size requirements.
fantasai@3385 2673 This value may cause the glyphs to overflow the line significantly.
fantasai@3385 2674 </dl>
kojiishi@7001 2675 -->
fantasai@2934 2676 <h2 class="no-num" id="changes">Changes</h2>
fantasai@2934 2677 <h3 class="no-num" id="recent-changes">
fantasai@7004 2678 Changes since the <a href="http://www.w3.org/TR/2012/WD-css3-writing-modes-20120501/">May
fantasai@6051 2679 2012 CSS Writing Modes Module Level 3 <abbr title="Working Draft">WD</abbr></a></h3>
fantasai@6051 2680
fantasai@6051 2681 <p>Major changes include:</p>
fantasai@6051 2682 <ul>
fantasai@6051 2683 <li>Replaced 'unicode-bidi' value of ''isolate bidi-override'' with single keyword ''isolate-override''.
fantasai@6076 2684 <li>Clarified that bidi isolated content does not affect plaintext heuristics of the containing paragraph.
fantasai@7009 2685 <li>Lots of other clarifications to bidi.
fantasai@7004 2686 <li>Renamed ''mixed-right'' value of 'text-orientation' to ''mixed''.
fantasai@7009 2687 <li>Updated references to UTR50 for orientation of characters in Unicode
fantasai@7009 2688 and improved text defining vertical typesetting rules.
fantasai@7009 2689 <li>Fixed errors and clarified auto-sizing rules for orthogonal flows.
fantasai@7009 2690 <li>Replaced Appendix D with references to the new [[!CSS3-SIZING]] module.
fantasai@7009 2691 <li>Removed 'text-combine-mode' property.
fantasai@7009 2692 <li>Removed all 'text-combine-horizontal' values except ''none'' and ''all''.
fantasai@7009 2693 <li>Defined effect of 'text-combine-horizontal' on line-breaking.
fantasai@6051 2694 </ul>
fantasai@6051 2695
fantasai@6051 2696 <h3 class="no-num" id="changes-201109">
fantasai@7004 2697 Changes since the <a href="http://www.w3.org/TR/2011/WD-css3-writing-modes-20110901/">September
fantasai@2934 2698 2011 CSS Writing Modes Module Level 3 <abbr title="Working Draft">WD</abbr></a></h3>
fantasai@2934 2699
fantasai@2934 2700 <p>Major changes include:</p>
fantasai@2934 2701 <ul>
fantasai@4501 2702 <li>Hooked up vertical typesetting details to UTR50.
fantasai@5573 2703 <li>Removed concept of "typographic modes".
fantasai@5653 2704 <li>Altered <a href="#orthogonal-auto">orthogonal sizing</a>
fantasai@5573 2705 to take into account the fill-available size; now the minimum of the
fantasai@5573 2706 fill-available and ICB size is used to resolve 'auto' sizes.
fantasai@5573 2707 <li>Renamed ''digits'' to ''numeric'' and ''ascii-digits'' to ''digits'' for 'text-combine-horizontal'.
fantasai@5573 2708 <li>Defined interaction of 'text-combine-horizontal' and 'text-transform'.
fantasai@2934 2709 </ul>
fantasai@2934 2710
fantasai@3396 2711 <h2 id="conformance">
fantasai@3396 2712 Conformance</h2>
fantasai@3396 2713
fantasai@3396 2714 <h3 id="conventions">
fantasai@3396 2715 Document Conventions</h3>
fantasai@3396 2716
fantasai@3396 2717 <p>Conformance requirements are expressed with a combination of
fantasai@3396 2718 descriptive assertions and RFC 2119 terminology. The key words “MUST”,
fantasai@3396 2719 “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
fantasai@3396 2720 “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
fantasai@3396 2721 document are to be interpreted as described in RFC 2119.
fantasai@3396 2722 However, for readability, these words do not appear in all uppercase
fantasai@3396 2723 letters in this specification.
fantasai@3396 2724
fantasai@3396 2725 <p>All of the text of this specification is normative except sections
fantasai@3396 2726 explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
fantasai@3396 2727
fantasai@3396 2728 <p>Examples in this specification are introduced with the words “for example”
fantasai@3396 2729 or are set apart from the normative text with <code>class="example"</code>,
fantasai@3396 2730 like this:
fantasai@3396 2731
fantasai@3396 2732 <div class="example">
fantasai@3396 2733 <p>This is an example of an informative example.</p>
fantasai@3396 2734 </div>
fantasai@3396 2735
fantasai@3396 2736 <p>Informative notes begin with the word “Note” and are set apart from the
fantasai@3396 2737 normative text with <code>class="note"</code>, like this:
fantasai@3396 2738
fantasai@3396 2739 <p class="note">Note, this is an informative note.</p>
fantasai@3396 2740
fantasai@3396 2741 <h3 id="conformance-classes">
fantasai@3396 2742 Conformance Classes</h3>
fantasai@3396 2743
fantasai@3398 2744 <p>Conformance to CSS Writing Modes Level 3
fantasai@3396 2745 is defined for three conformance classes:
fantasai@3396 2746 <dl>
fantasai@3396 2747 <dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
fantasai@3396 2748 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
fantasai@3396 2749 style sheet</a>.
fantasai@3396 2750 <dt><dfn>renderer</dfn></dt>
fantasai@3396 2751 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
fantasai@3396 2752 that interprets the semantics of a style sheet and renders
fantasai@3396 2753 documents that use them.
fantasai@3396 2754 <dt><dfn id="authoring-tool">authoring tool</dfn></dt>
fantasai@3396 2755 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
fantasai@3396 2756 that writes a style sheet.
fantasai@3396 2757 </dl>
fantasai@3396 2758
fantasai@3398 2759 <p>A style sheet is conformant to CSS Writing Modes Level 3
fantasai@3396 2760 if all of its declarations that use properties defined in this module
fantasai@3396 2761 have values that are valid according to the generic CSS grammar and the
fantasai@3396 2762 individual grammars of each property as given in this module.
fantasai@3396 2763
fantasai@3398 2764 <p>A renderer is conformant to CSS Writing Modes Level 3
fantasai@3396 2765 if, in addition to interpreting the style sheet as defined by the
fantasai@3396 2766 appropriate specifications, it supports all the features defined
fantasai@3398 2767 by CSS Writing Modes Level 3 by parsing them correctly
fantasai@3396 2768 and rendering the document accordingly. However, the inability of a
fantasai@3396 2769 UA to correctly render a document due to limitations of the device
fantasai@3396 2770 does not make the UA non-conformant. (For example, a UA is not
fantasai@3396 2771 required to render color on a monochrome monitor.)
fantasai@3396 2772
fantasai@3398 2773 <p>An authoring tool is conformant to CSS Writing Modes Level 3
fantasai@3396 2774 if it writes style sheets that are syntactically correct according to the
fantasai@3396 2775 generic CSS grammar and the individual grammars of each feature in
fantasai@3396 2776 this module, and meet all other conformance requirements of style sheets
fantasai@3396 2777 as described in this module.
fantasai@3396 2778
fantasai@3396 2779 <h3 id="partial">
fantasai@3396 2780 Partial Implementations</h3>
fantasai@3396 2781
fantasai@3396 2782 <p>So that authors can exploit the forward-compatible parsing rules to
fantasai@3396 2783 assign fallback values, CSS renderers <strong>must</strong>
fantasai@3396 2784 treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
fantasai@3396 2785 as appropriate</a>) any at-rules, properties, property values, keywords,
fantasai@3396 2786 and other syntactic constructs for which they have no usable level of
fantasai@3396 2787 support. In particular, user agents <strong>must not</strong> selectively
fantasai@3396 2788 ignore unsupported component values and honor supported values in a single
fantasai@3396 2789 multi-value property declaration: if any value is considered invalid
fantasai@3396 2790 (as unsupported values must be), CSS requires that the entire declaration
fantasai@3396 2791 be ignored.</p>
fantasai@3396 2792
fantasai@3396 2793 <h3 id="experimental">
fantasai@3396 2794 Experimental Implementations</h3>
fantasai@3396 2795
fantasai@3396 2796 <p>To avoid clashes with future CSS features, the CSS2.1 specification
fantasai@3396 2797 reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
fantasai@3396 2798 syntax</a> for proprietary and experimental extensions to CSS.
fantasai@3396 2799
fantasai@3396 2800 <p>Prior to a specification reaching the Candidate Recommendation stage
fantasai@3396 2801 in the W3C process, all implementations of a CSS feature are considered
fantasai@3396 2802 experimental. The CSS Working Group recommends that implementations
fantasai@3396 2803 use a vendor-prefixed syntax for such features, including those in
fantasai@3396 2804 W3C Working Drafts. This avoids incompatibilities with future changes
fantasai@3396 2805 in the draft.
fantasai@3396 2806 </p>
fantasai@3396 2807
fantasai@3396 2808 <h3 id="testing">Non-Experimental Implementations</h3>
fantasai@3396 2809
fantasai@3396 2810 <p>Once a specification reaches the Candidate Recommendation stage,
fantasai@3396 2811 non-experimental implementations are possible, and implementors should
fantasai@3396 2812 release an unprefixed implementation of any CR-level feature they
fantasai@3396 2813 can demonstrate to be correctly implemented according to spec.
fantasai@3396 2814
fantasai@3396 2815 <p>To establish and maintain the interoperability of CSS across
fantasai@3396 2816 implementations, the CSS Working Group requests that non-experimental
fantasai@3396 2817 CSS renderers submit an implementation report (and, if necessary, the
fantasai@3396 2818 testcases used for that implementation report) to the W3C before
fantasai@3396 2819 releasing an unprefixed implementation of any CSS features. Testcases
fantasai@3396 2820 submitted to W3C are subject to review and correction by the CSS
fantasai@3396 2821 Working Group.
fantasai@3396 2822
fantasai@3396 2823 <p>Further information on submitting testcases and implementation reports
fantasai@3396 2824 can be found from on the CSS Working Group's website at
fantasai@3396 2825 <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
fantasai@3396 2826 Questions should be directed to the
fantasai@3396 2827 <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
fantasai@3396 2828 mailing list.
fantasai@3396 2829
fantasai@3396 2830 <h3 id="cr-exit-criteria">
fantasai@3396 2831 CR Exit Criteria</h3>
fantasai@3396 2832
fantasai@3396 2833 <p>
fantasai@3396 2834 For this specification to be advanced to Proposed Recommendation,
fantasai@3396 2835 there must be at least two independent, interoperable implementations
fantasai@3396 2836 of each feature. Each feature may be implemented by a different set of
fantasai@3396 2837 products, there is no requirement that all features be implemented by
fantasai@3396 2838 a single product. For the purposes of this criterion, we define the
fantasai@3396 2839 following terms:
fantasai@3396 2840
fantasai@3396 2841 <dl>
fantasai@3396 2842 <dt>independent <dd>each implementation must be developed by a
fantasai@3396 2843 different party and cannot share, reuse, or derive from code
fantasai@3396 2844 used by another qualifying implementation. Sections of code that
fantasai@3396 2845 have no bearing on the implementation of this specification are
fantasai@3396 2846 exempt from this requirement.
fantasai@3396 2847
fantasai@3396 2848 <dt>interoperable <dd>passing the respective test case(s) in the
fantasai@3396 2849 official CSS test suite, or, if the implementation is not a Web
fantasai@3396 2850 browser, an equivalent test. Every relevant test in the test
fantasai@3396 2851 suite should have an equivalent test created if such a user
fantasai@3396 2852 agent (UA) is to be used to claim interoperability. In addition
fantasai@3396 2853 if such a UA is to be used to claim interoperability, then there
fantasai@3396 2854 must one or more additional UAs which can also pass those
fantasai@3396 2855 equivalent tests in the same way for the purpose of
fantasai@3396 2856 interoperability. The equivalent tests must be made publicly
fantasai@3396 2857 available for the purposes of peer review.
fantasai@3396 2858
fantasai@3396 2859 <dt>implementation <dd>a user agent which:
fantasai@3396 2860
fantasai@3396 2861 <ol class=inline>
fantasai@3396 2862 <li>implements the specification.
fantasai@3396 2863
fantasai@3396 2864 <li>is available to the general public. The implementation may
fantasai@3396 2865 be a shipping product or other publicly available version
fantasai@3396 2866 (i.e., beta version, preview release, or “nightly build”).
fantasai@3396 2867 Non-shipping product releases must have implemented the
fantasai@3396 2868 feature(s) for a period of at least one month in order to
fantasai@3396 2869 demonstrate stability.
fantasai@3396 2870
fantasai@3396 2871 <li>is not experimental (i.e., a version specifically designed
fantasai@3396 2872 to pass the test suite and is not intended for normal usage
fantasai@3396 2873 going forward).
fantasai@3396 2874 </ol>
fantasai@3396 2875 </dl>
fantasai@3396 2876
fantasai@3396 2877 <p>The specification will remain Candidate Recommendation for at least
fantasai@3396 2878 six months.
fantasai@3396 2879
fantasai@2827 2880 <h2 class="no-num" id="acknowledgements">
fantasai@2827 2881 Acknowledgements</h2>
fantasai@2051 2882
fantasai@6066 2883 <p>John Daggett, Martin Heijdra, Laurentiu Iancu,
kojiishi@3010 2884 Yasuo Kida, Tatsuo Kobayashi, Toshi Kobayashi,
fantasai@6066 2885 Ken Lunde, Nat McCully, Eric Muller,
fantasai@6066 2886 Paul Nelson, Kenzou Onozawa, Dwayne Robinson,
fantasai@6066 2887 Michel Suignard, Taro Yamamoto, Steve Zilles</p>
fantasai@2058 2888
fantasai@3362 2889 <h2 id="character-properties" class="no-num">Appendix A.
fantasai@2993 2890 Characters and Properties</h2>
fantasai@2993 2891
fantasai@3362 2892 <p>Unicode defines three codepoint-level properties that are referenced
fantasai@2993 2893 in CSS Writing Modes:
fantasai@2993 2894 <dl>
fantasai@2993 2895 <dt><a href="http://www.unicode.org/reports/tr11/#Definitions">East Asian width</a>
fantasai@3047 2896 <dd>Defined in [[!UAX11]] and given as the East_Asian_Width property
fantasai@3047 2897 in the Unicode Character Database [[!UAX44]].
fantasai@2993 2898 <dt><a href="http://www.unicode.org/reports/tr44/#General_Category_Values">General Category</a>
fantasai@3047 2899 <dd>Defined in [[!UAX44]] and given as the General_Category property
fantasai@3047 2900 in the Unicode Character Database [[!UAX44]].
fantasai@2993 2901 <dt><a href="http://www.unicode.org/reports/tr24/#Values">Script property</a>
fantasai@3047 2902 <dd>Defined in [[!UAX24]] and given as the Script property
fantasai@3047 2903 in the Unicode Character Database [[!UAX44]]. (UAs should
fantasai@2993 2904 include any ScriptExtensions.txt assignments in this mapping.)
fantasai@2993 2905 </dl>
fantasai@2993 2906
fantasai@2993 2907 <p id=grapheme-cluster>In several sections (as noted), the term
fantasai@2993 2908 <dfn>character</dfn> is defined as <em>extended grapheme cluster</em>
fantasai@2993 2909 per [[!UAX29]]. It is roughly equivalent to what a language user
fantasai@2993 2910 considers to be a character or a basic unit of the script (which
fantasai@2993 2911 might not be a single Unicode codepoint).
fantasai@3912 2912 The UA may further tailor this definition as appropriate to match
fantasai@3912 2913 typographic convention. For example, when typesetting ''upright'',
fantasai@3912 2914 Tibetan tsek and shad marks are kept with the preceding letters,
fantasai@3913 2915 rather than treated as an independent cluster.
fantasai@2993 2916
kojiishi@6058 2917 <p>Unicode defines properties for characters, but for 'text-orientation',
fantasai@2993 2918 it is necessary to determine the properties of a grapheme cluster.
fantasai@2993 2919 For the purposes of CSS Writing Modes, the properties of a grapheme
jackalmage@6884 2920 cluster are given by its base character—except in two cases:
fantasai@3163 2921 <ul>
fantasai@3163 2922 <li>Grapheme clusters formed with an Enclosing Mark (Me) of the Common
fantasai@2993 2923 script are considered to be Other Symbols (So) in the Common script.
fantasai@2993 2924 They are assumed to have the same Unicode properties as the
fantasai@2993 2925 Replacement Character U+FFFD.
fantasai@3163 2926 <li>Grapheme clusters formed with a Space Separator (Zs) as the base
fantasai@3163 2927 are considered to be Modifier Symbols (Sk). They are assumed to have
fantasai@3163 2928 the same East Asian Width property as the base, but take their other
fantasai@3163 2929 properties from the first combining character in the sequence.
fantasai@3163 2930 </ul>
fantasai@2993 2931
fantasai@6070 2932 <h2 id="bidi-html" class=no-num>
fantasai@7003 2933 Appendix B: Bidi Rules for HTML 4</h2>
fantasai@6070 2934
fantasai@6070 2935 <p>The style sheet rules that would achieve the bidi behaviors specified
fantasai@6070 2936 in [[HTML401]] for the HTML Strict doctype are given below:
fantasai@6070 2937 <pre>
fantasai@6070 2938 /* HTML dir attribute creates an embedding */
fantasai@6070 2939 *[dir="ltr"] { direction: ltr; unicode-bidi: embed; }
fantasai@6070 2940 *[dir="rtl"] { direction: rtl; unicode-bidi: embed; }
fantasai@6070 2941
fantasai@6070 2942 /* BDO element creates an override */
fantasai@6070 2943 bdo[dir="ltr"] { direction: ltr; unicode-bidi: bidi-override; }
fantasai@6070 2944 bdo[dir="rtl"] { direction: rtl; unicode-bidi: bidi-override; }
fantasai@6070 2945
fantasai@6070 2946 /* HTML4.01:8.2.6 - preserve bidi behavior if 'display' is changed */
fantasai@6070 2947 html, body,
fantasai@6070 2948 div, address, blockquote, p,
fantasai@6070 2949 ul, ol, li, dl, dt, dd,
fantasai@6070 2950 fieldset, form,
fantasai@6070 2951 h1, h2, h3, h4, h5, h6,
fantasai@6070 2952 { unicode-bidi: isolate; }
fantasai@6070 2953 </pre>
fantasai@6070 2954
fantasai@6070 2955 <h2 class="no-num" id="script-orientations">Appendix C:
fantasai@5566 2956 Vertical Scripts in Unicode</h2>
fantasai@6066 2957 <p><em>This section is informative.</em></p>
fantasai@2478 2958
fantasai@5566 2959 <p>This appendix lists the vertical and bi-orientational scripts in Unicode 6.0
fantasai@6066 2960 [[!UNICODE]] and their transformation from horizontal to vertical orientation.
fantasai@6066 2961 Any script not listed explicitly is assumed to be <i>horizontal-only</i>.
fantasai@6066 2962 The script classification of Unicode characters is given by [[!UAX24]].
fantasai@2478 2963
fantasai@2830 2964 <table class="data">
fantasai@5566 2965 <caption>Vertical Scripts in Unicode</caption>
fantasai@2478 2966 <thead>
fantasai@6066 2967 <tr><th>Code <th>Name <th>Transform (Clockwise) <th>Vertical Intrinsic Direction
fantasai@2478 2968 </thead>
fantasai@2478 2969 <tbody>
fantasai@6066 2970 <tr><td>Bopo <td>Bopomofo <th>0&deg; <th>ttb
fantasai@6066 2971 <tr><td>Egyp <td>Egyptian Hieroglyphs <th>0&deg; <th>ttb
fantasai@6066 2972 <tr><td>Hira <td>Hiragana <th>0&deg; <th>ttb
fantasai@6066 2973 <tr><td>Kana <td>Katakana <th>0&deg; <th>ttb
fantasai@6066 2974 <tr><td>Hani <td>Han <th>0&deg; <th>ttb
fantasai@6066 2975 <tr><td>Hang <td>Hangul <th>0&deg; <th>ttb
fantasai@6066 2976 <tr><td>Merc <td>Meroitic Cursive <th>0&deg; <th>ttb
fantasai@6066 2977 <tr><td>Mero <td>Meroitic Hieroglyphs <th>0&deg; <th>ttb
fantasai@6066 2978 <tr><td>Mong <td>Mongolian <th>90&deg; <th>ttb
fantasai@6066 2979 <tr><td>Ogam <td>Ogham <th>-90&deg; <th>btt
fantasai@6066 2980 <tr><td>Orkh <td>Old Turkic <th>-90&deg; <th>ttb
fantasai@6066 2981 <tr><td>Phag <td>Phags Pa <th>90&deg; <th>ttb
fantasai@6066 2982 <tr><td>Yiii <td>Yi <th>0&deg; <th>ttb
fantasai@2478 2983 </tbody>
fantasai@2478 2984 </table>
fantasai@2478 2985
fantasai@2830 2986 <p><strong>Exceptions:</strong>
fantasai@2927 2987 For the purposes of this specification, all fullwidth (F) and wide (W) characters
fantasai@6066 2988 are treated as belonging to a vertical script,
fantasai@6066 2989 and halfwidth characters (H) are treated as belonging ot a horizontal script.
fantasai@2830 2990 [[!UAX11]]
fantasai@5566 2991
fantasai@6066 2992 <p class="note">
fantasai@6066 2993 CSS3 Writing Modes cannot correctly handle either Ogham or Old Turkic.
fantasai@6066 2994 It is recommended that ''text-orientation: sideways-left'' be used to typeset these scripts.
fantasai@6066 2995 A future version of CSS may define automatic handling of these scripts.
fantasai@6066 2996
fantasai@6066 2997 <p class="note">Note that for vertical-only characters (such as Mongolian and Phags Pa letters),
fantasai@6066 2998 the glyphs in the Unicode code charts are shown in their vertical orientation.
fantasai@5641 2999 In horizontal text, they are typeset in a 90&deg; counter-clockwise
fantasai@5641 3000 rotation from this orientation.
fantasai@5641 3001
fantasai@2827 3002 <h2 class="no-num">
fantasai@2827 3003 References</h2>
bert@2187 3004
fantasai@2827 3005 <h3 class="no-num">
fantasai@2827 3006 Normative references</h3>
bert@2187 3007 <!--normative-->
bert@2187 3008
fantasai@2827 3009 <h3 class="no-num">
fantasai@2827 3010 Other references</h3>
bert@2187 3011 <!--informative-->
bert@2187 3012
fantasai@2726 3013
fantasai@2827 3014 <h2 class="no-num">
fantasai@2827 3015 Property Index</h2>
fantasai@2771 3016 <!-- properties -->
fantasai@2771 3017 <!-- Add alphabetic index? -->
fantasai@365 3018 </body>
fantasai@365 3019 </html>

mercurial