8000 csswg-drafts/css-writing-modes/Overview.html at 4e9863f520f771ddd90fa6b10282dd111ddbbd3b · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
executable file
·
2727 lines (2357 loc) · 210 KB

File metadata and controls

executable file
·
2727 lines (2357 loc) · 210 KB
<td><a class=css data-link-type=maybe href=#valuedef-embed title=embed>embed</a>
<td><a class=css data-link-type=maybe href=#valuedef-isolate title=isolate>isolate</a>
<tr><th><abbr title="all text consisted of strong characters of the element’s 'direction'.">override</abbr>
<td><a class=css data-link-type=maybe href=#valuedef-bidi-override title=bidi-override>bidi-override</a>
<td><a class=css data-link-type=maybe href=#valuedef-isolate-override title=isolate-override>isolate-override</a>
<tr><th><abbr title="the element were a standalone paragraph ordered using UAX9 heuristics.">plaintext</abbr>
<td>—
<td><a class=css data-link-type=maybe href=#valuedef-plaintext title=plaintext>plaintext</a>
</tbody>
</table>
<p>Values for this property have the following (normative) meanings:</p>
<dl>
<dt><dfn class=css-code data-dfn-for=unicode-bidi data-dfn-type=value data-export="" id=valuedef-normal>normal<a class=self-link href=#valuedef-normal></a></dfn></dt>
<dd>The element does not open an additional level of embedding with
respect to the bidirectional algorithm. For inline elements,
implicit reordering works across element boundaries.</dd>
<dt><dfn class=css-code data-dfn-for=unicode-bidi data-dfn-type=value data-export="" id=valuedef-embed>embed<a class=self-link href=#valuedef-embed></a></dfn></dt>
<dd>If the element is inline, this value creates a <dfn data-dfn-type=dfn data-export="" id=directional-embedding>directional embedding<a class=self-link href=#directional-embedding></a></dfn>
by opening an additional level of embedding with respect to the bidirectional algorithm.
The direction of this embedding level is given by the <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a>
property. Inside the element, reordering is done implicitly. This
corresponds to adding a LRE (U+202A), for <a class=css data-link-type=propdesc href=#propdef-direction title=direction>direction: ltr</a>, or RLE
(U+202B), for <a class=css data-link-type=propdesc href=#propdef-direction title=direction>direction: rtl</a>, at the start of the element and a PDF
(U+202C) at the end of the element.
<span class=note>This value has no effect on elements that are
not inline.</span></dd>
<dt><dfn class=css-code data-dfn-for=unicode-bidi data-dfn-type=value data-export="" id=valuedef-isolate>isolate<a class=self-link href=#valuedef-isolate></a></dfn></dt>
<dd>On an inline element, this <dfn data-dfn-type=dfn data-export="" id=bidi-isolate title="bidi-isolate|bidi-isolated|bidi isolation|isolation">bidi-isolates<a class=self-link href=#bidi-isolate></a></dfn> its contents.
This is similar to a directional embedding (and increases the embedding level accordingly)
except that each sequence of inline-level boxes
uninterrupted by any block boundary or <a data-link-type=dfn href=#forced-paragraph-break title="forced paragraph break">forced paragraph break</a>
is treated as an <dfn data-dfn-type=dfn data-noexport="" id=isolated-sequence>isolated sequence<a class=self-link href=#isolated-sequence></a></dfn>:
<ul>
<li>the content within the sequence is ordered
as if inside an independent paragraph
with the base directionality specified by the element’s <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> property.
<li>for the purpose of bidi resolution in its containing bidi paragraph,
the sequence is treated as if it were a single Object Replacement Character (U+FFFC).
</ul>
In effect, neither is the content inside the element bidi-affected
by the content surrounding the element,
nor is the content surrounding the element bidi-affected by the
content or specified directionality of the element.
However, <a data-link-type=dfn href=#forced-paragraph-break title="forced paragraph breaks">forced paragraph breaks</a> within the element still create
a corresponding break in the containing paragraph.
<p class=note>In Unicode 6.3 and beyond,
this will correspond to adding an LRI (U+2066), for <a class=css data-link-type=propdesc href=#propdef-direction title=direction>direction: ltr</a>,
or RLI (U+2067), for <a class=css data-link-type=propdesc href=#propdef-direction title=direction>direction: rtl</a>, at the start of the element,
and a PDI (U+2069) at the end of the element.
<p class=note>This value has no effect on elements that are not inline.
<dt><dfn class=css-code data-dfn-for=unicode-bidi data-dfn-type=value data-export="" id=valuedef-bidi-override>bidi-override<a class=self-link href=#valuedef-bidi-override></a></dfn></dt>
<dd>This value puts the element’s immediate content in a <dfn data-dfn-type=dfn data-export="" id=directional-override>directional override<a class=self-link href=#directional-override></a></dfn>.
For an inline, this means that the element acts like a <a data-link-type=dfn href=#directional-embedding title="directional embedding">directional embedding</a>
in the bidirectional algorithm,
except that reordering within it is strictly in sequence according to the
<a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> property; the implicit part of the bidirectional algorithm
is ignored. This corresponds to adding a LRO (U+202D), for <a class=css data-link-type=propdesc href=#propdef-direction title=direction>direction: ltr</a>,
or RLO (U+202E), for <a class=css data-link-type=propdesc href=#propdef-direction title=direction>direction: rtl</a>, at the start of the
element and a PDF (U+202C) at the end of the element.
If the element is a block container,
the override is applied to an anonymous inline element
that surrounds all of its content.</dd>
<dt><dfn class=css-code data-dfn-for=unicode-bidi data-dfn-type=value data-export="" id=valuedef-isolate-override>isolate-override<a class=self-link href=#valuedef-isolate-override></a></dfn></dt>
<dd>This combines the <a data-link-type=dfn href=#bidi-isolate title=isolation>isolation</a> behavior of <a class=css data-link-type=maybe href=#valuedef-isolate title=isolate>isolate</a> with the
<a data-link-type=dfn href=#directional-override title="directional override">directional override</a> behavior of <a class=css data-link-type=maybe href=#valuedef-bidi-override title=bidi-override>bidi-override</a>: to surrounding content,
it is equivalent to <a class=css data-link-type=maybe href=#valuedef-isolate title=isolate>isolate</a>, but within the element content
is ordered as if <a class=css data-link-type=maybe href=#valuedef-bidi-override title=bidi-override>bidi-override</a> were specified.
<dt><dfn class=css-code data-dfn-for=unicode-bidi data-dfn-type=value data-export="" id=valuedef-plaintext>plaintext<a class=self-link href=#valuedef-plaintext></a></dfn></dt>
<dd><p>This value behaves as <a class=css data-link-type=maybe href=#valuedef-isolate title=isolate>isolate</a> except that for the purposes of
the Unicode bidirectional algorithm, the base directionality of each
of the element’s <a data-link-type=dfn href=#bidi-paragraph title="bidi paragraphs">bidi paragraphs</a> (if a block container)
or <a data-link-type=dfn href=#isolated-sequence title="isolated sequences">isolated sequences</a> (if an inline)
is determined by following the heuristic in rules P2 and P3
of the Unicode bidirectional algorithm
(rather than by using the <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> property of the element).
<p class=note>In Unicode 6.3 and beyond, for inline elements
this will correspond to adding an FSI (U+2068) at the start of the element,
and a PDI (U+2069) at the end of the element.
</dl>
<p class=note>Because the <a class=property data-link-type=propdesc href=#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a> property does not inherit,
setting <a class=css data-link-type=maybe href=#valuedef-bidi-override title=bidi-override>bidi-override</a> or <a class=css data-link-type=maybe href=#valuedef-plaintext title=plaintext>plaintext</a> on a block element will
not affect any descendant blocks. Therefore these values are best
used on blocks and inlines that do not contain any block-level
structures.
<p class=note>Note that <a class=property data-link-type=propdesc href=#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a> does not affect the <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a>
property even in the case of <a class=css data-link-type=maybe href=#valuedef-plaintext title=plaintext>plaintext</a>, and thus does not affect
<a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a>-dependent layout calculations.
<p>The final order of characters within each <a data-link-type=dfn href=#bidi-paragraph title="bidi paragraph">bidi paragraph</a> is the
same as if the bidi control codes had been added as described above,
markup had been stripped, and the resulting character sequence had
been passed to an implementation of the Unicode bidirectional
algorithm for plain text that produced the same line-breaks as the
styled text.
<p>In this process, replaced elements with <a class=css data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visuren.html#propdef-display title=display>display: inline</a>
are treated as neutral characters,
unless their <a class=property data-link-type=propdesc href=#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a> property is either <a class=css data-link-type=maybe href=#valuedef-embed title=embed>embed</a> or <a class=css data-link-type=maybe href=#valuedef-bidi-override title=bidi-override>bidi-override</a>,
in which case they are treated as strong characters
in the <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> specified for the element.
All other atomic inline-level boxes are treated as neutral characters
always.</p>
<p>If an inline element is broken around a <a data-link-type=dfn href=#bidi-paragraph title="bidi paragraph">bidi paragraph</a>
boundary (e.g. if split by a block or <a data-link-type=dfn href=#forced-paragraph-break title="forced paragraph break">forced paragraph break</a>), then
the bidi control codes assigned to the end of the element
are added before the interruption and the codes assigned to the
start of the element are added after it. (In other words, any embedding
levels or overrides started by the element are closed at the paragraph
break and reopened on the other side of it.)
<div class=example>
<p>For example, where &lt;BR/&gt; is a <a data-link-type=dfn href=#forced-paragraph-break title="forced paragraph break">forced paragraph break</a>
the bidi ordering is identical between
<pre>&lt;para&gt;...&lt;i1&gt;&lt;i2&gt;...&lt;BR/&gt;...&lt;/i2&gt;&lt;i1&gt;...&lt;/para&gt;</pre> <p>and
<pre>&lt;para&gt;...&lt;i1&gt;&lt;i2&gt;...&lt;/i2&gt;&lt;i1&gt;&lt;BR/&gt;&lt;i1&gt;&lt;i2&gt;...&lt;/i2&gt;&lt;i1&gt;...&lt;/para&gt;</pre> <p>for all values of <a class=property data-link-type=propdesc href=#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a> on inline elements &lt;i1&gt; and &lt;i2&gt;.
</div>
<p class=note>
Because the Unicode algorithm has a limit of 61 levels of embedding,
care should be taken not to use <a class=property data-link-type=propdesc href=#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a>
with a value other than <a class=css data-link-type=maybe href=#valuedef-normal title=normal>normal</a> unless appropriate.
In particular, a value of <span class=css data-link-type=maybe title=inherit>inherit</span>
should be used with extreme caution. However, for elements that are,
in general, intended to be displayed as blocks, a setting of
<a class=css data-link-type=propdesc href=#propdef-unicode-bidi title=unicode-bidi>unicode-bidi: isolate</a> is preferred to keep the element together
in case the <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visuren.html#propdef-display title=display>display</a> is changed to <span class=css data-link-type=maybe title=inline>inline</span>
(see example below).</p>
<h3 class="heading settled heading" data-level=2.3 id=bidi-example><span class=secno>2.3 </span><span class=content>
Example of Bidirectional Text</span><a class=self-link href=#bidi-example></a></h3>
<p>The following example shows an XML document with bidirectional
text. It illustrates an important design principle: document language
designers should take bidi into account both in the language proper
(elements and attributes) and in any accompanying style sheets. The
style sheets should be designed so that bidi rules are separate from
other style rules, and such rules should not be overridden by other
style sheets so that the document language’s bidi behavior is preserved.</p>
<div class=example>
<p>In this example, lowercase letters stand for inherently left-to-right
characters and uppercase letters represent inherently right-to-left
characters. The text stream is shown in logical backing store order.</p>
<pre class=xml-example><code class=xml>
&lt;section dir=rtl&gt;
&lt;para&gt;HEBREW1 HEBREW2 english3 HEBREW4 HEBREW5&lt;/para&gt;
&lt;para&gt;HEBREW6 &lt;emphasis&gt;HEBREW7&lt;/emphasis&gt; HEBREW8&lt;/para&gt;
&lt;/section&gt;
&lt;section dir=ltr&gt;
&lt;para&gt;english9 english10 english11 HEBREW12 HEBREW13&lt;/para&gt;
&lt;para&gt;english14 english15 english16&lt;/para&gt;
&lt;para&gt;english17 &lt;quote dir=rtl&gt;HEBREW18 english19 HEBREW20&lt;/quote&gt;&lt;/para&gt;
&lt;/section&gt;
</code></pre>
<p>Since this is arbitrary XML, the style sheet is responsible for
setting the writing direction. This is the style sheet:</p>
<pre>/* Rules for bidi */
[dir=ltr] {direction: rtl;}
[dir=rtl] {direction: ltr;}
quote {unicode-bidi: isolate;}
/* Rules for presentation */
section, para {display: block;}
emphasis {font-weight: bold;}
</pre>
<p>The first <code>&lt;section&gt;</code> element is a block with a right-to-left base direction,
the second <code>&lt;section&gt;</code> element is a block with a left-to-right base direction.
The <code>&lt;para&gt;</code>s are blocks that inherit the base direction from their parents.
Thus, the first two <code>&lt;para&gt;</code>s are read starting at the top right,
the final three are read starting at the top left.</p>
<p>The <code>&lt;emphasis&gt;</code> element is inline-level,
and since its value for <a class=property data-link-type=propdesc href=#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a> is <a class=css data-link-type=maybe href=#valuedef-normal title=normal>normal</a> (the initial value),
it has no effect on the ordering of the text.
The <code>&lt;quote&gt;</code> element, on the other hand,
creates an <a data-link-type=dfn href=#isolated-sequence title="isolated sequence">isolated sequence</a> with the given internal directionality.
<p>The formatting of this text might look like this if the line length
is long:</p>
<pre class=ascii-art> 5WERBEH 4WERBEH english3 2WERBEH 1WERBEH
8WERBEH <b>7WERBEH</b> 6WERBEH
english9 english10 english11 13WERBEH 12WERBEH
english14 english15 english16
english17 20WERBEH english19 18WERBEH
</pre>
<p>Note that the <code>&lt;quote&gt;</code> embedding causes
<samp>HEBREW18</samp> to be to the right of <samp>english19</samp>.
<p>If lines have to be broken, it might be more like this:</p>
<pre class=ascii-art> 2WERBEH 1WERBEH
-EH 4WERBEH english3
5WERB
-EH <b>7WERBEH</b> 6WERBEH
8WERB
english9 english10 en-
glish11 12WERBEH
13WERBEH
english14 english15
english16
english17 18WERBEH
20WERBEH english19
</pre>
<p>Because <samp>HEBREW18</samp> must be read before english19,
it is on the line above <samp>english19</samp>.
Just breaking the long line from the earlier formatting 82D7 would not have worked.
Note also that the first syllable from <samp>english19</samp>
might have fit on the previous line,
but hyphenation of left-to-right words in a right-to-left context, and vice versa,
is usually suppressed to avoid having to display a hyphen in the middle of a line.
</div>
<h3 class="heading settled heading" data-level=2.4 id=bidi-box-model><span class=secno>2.4 </span><span class=content>
Box model for inline elements in bidirectional context</span><a class=self-link href=#bidi-box-model></a></h3>
<p>Since bidi reordering can split apart and reorder text that is
logically contiguous, bidirectional text can cause an inline box
to be split and reordered within a line.
<p class=note>Note that in order to be able to flow inline boxes in a
uniform direction (either entirely left-to-right or entirely
right-to-left), anonymous inline boxes may have to be created.</p>
<p>For each line box, UAs must take the inline boxes generated for each
element and render the margins, borders and padding in visual order
(not logical order). The <a data-link-type=dfn href=#start title=start>start</a>-most box on the first line box
in which the element appears has the <a data-link-type=dfn href=#start title=start>start</a> edge’s margin, border,
and padding; and the end-most box on the last line box in which the
element appears has the <a data-link-type=dfn href=#end title=end>end</a> edge’s margin, border, and padding.
For example, in the <a class=css data-link-type=maybe href=#valuedef-horizontal-tb title=horizontal-tb>horizontal-tb</a> writing mode:
<ul>
<li>When the parent’s <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> property is <a class=css data-link-type=maybe href=#valuedef-ltr title=ltr>ltr</a>, the left-most
generated box of the first line box in which the element appears
has the left margin, left border and left padding, and the right-most
generated box of the last line box in which the element appears has
the right padding, right border and right margin.
<li>When the parent’s <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> property is <a class=css data-link-type=maybe href=#valuedef-rtl title=rtl>rtl</a>, the right-most
generated box of the first line box in which the element appears has
the right padding, right border and right margin, and the left-most
generated box of the last line box in which the element appears has
the left margin, left border and left padding.
</ul>
<p>Analogous rules hold for vertical writing modes.</p>
<p class=note>The <a class=property data-link-type=propdesc href=http://www.w3.org/TR/css3-background/#box-decoration-break title=box-decoration-break>box-decoration-break</a> property can override this
behavior to draw box decorations on both sides of each box. <a data-biblio-type=normative data-link-type=biblio href=#css3bg title=css3bg>[CSS3BG]</a> </p>
<h2 class="heading settled heading" data-level=3 id=vertical-intro><span class=secno>3 </span><span class=content>
Introduction to Vertical Text</span><a class=self-link href=#vertical-intro></a></h2>
<p><em>This subsection is non-normative.</em></p>
<p>In addition to extensions to CSS2.1’s support for bidirectional text,
this module introduces the rules and properties needed to support vertical
text layout in CSS.
<p>Unlike languages that use the Latin script which are primarily laid out
horizontally, Asian languages such as Chinese and Japanese can be laid out
vertically. The Japanese example below shows the same text laid out
horizontally and vertically. In the horizontal case, text is read
from left to right, top to bottom. For the vertical case, the text is
read top to bottom, right to left.
Indentation from the left edge in the left-to-right horizontal case
translates to indentation from the top edge in the top-to-bottom vertical
case.
<div class=figure>
<p><img alt="A comparison of horizontal and vertical Japanese shows that
although the lines rotate, the characters remain upright.
Some glyphs, however change: a period mark shifts from the
bottom left of its glyph box to the top right. Running
headers, however, may remain
laid out horizontally across the top of the page." src=vert-horiz-comparison.png></p>
<p class=caption>Comparison of vertical and horizontal Japanese: iBunko application (iOS)</p>
</div>
<p class=note>For Chinese and Japanese lines are ordered either right
to left or top to bottom, while for Mongolian and Manchu lines are
ordered left to right.</p>
<p>The change from horizontal to vertical writing can affect not just the
layout, but also the typesetting. For example, the position of a punctuation
mark within its spacing box can change from the horizontal to the
vertical case, and in some cases alternate glyphs are used.
<p>Vertical text that includes Latin script text or text from other scripts
normally displayed horizontally can display that text in a number of
ways. For example, Latin words can be rotated sideways, or each letter
can be oriented upright:
<div class=figure>
<p><img alt="A dictionary definition for ヴィルス
might write the English word 'virus' rotated 90° clockwise,
but stack the letters of the initialisms 'RNA' and 'DNA' upright." src=vert-latin-layouts.png></p>
<p class=caption>Examples of Latin in vertical Japanese: Daijirin Viewer 1.4 (iOS)
</div>
<p>In some special cases such as two-digit numbers in dates, text is fit
compactly into a single vertical character box:
<div class=figure id=fig-mac>
<p><img alt="An excerpt from MacFan shows several possible vertical layouts
for numbers: the two-digit month and day are written as
horizontal-in-vertical blocks; the years are written with
each character upright; except in the English phrase
“for Mac 2011”, where the date is rotated to
match the rotated Latin." src=vert-number-layouts.png></p>
<p class=caption>Mac Fan, December 2010, p.49</p>
</div>
<p>Layouts often involve a mixture of vertical and horizontal elements:
<div class=figure>
<p><img alt="Magazines often mix horizontal and vertical layout; for
example, using one orientation for the main article text
and a different one for sidebar or illustrative content." src=vert-horiz-combination.png></p>
<p class=caption>Mixture of vertical and horizontal elements</p>
</div>
<p>Vertical text layouts also need to handle bidirectional text layout;
clockwise-rotated Arabic, for example, is laid out bottom-to-top.
<h3 class="heading settled heading" data-level=3.1 id=writing-mode><span class=secno>3.1 </span><span class=content>
Block Flow Direction: the <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> property</span><a class=self-link href=#writing-mode></a></h3>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-writing-mode>writing-mode<a class=self-link href=#propdef-writing-mode></a></dfn><tr><th>Value:<td>horizontal-tb | vertical-rl | vertical-lr<tr><th>Initial:<td>horizontal-tb<tr><th>Applies to:<td>All elements except table row groups, table column groups, table rows, and table columns<tr><th>Inherited:<td>yes<tr><th>Media:<td>visual<tr><th>Computed value:<td>specified value<tr><th>Canonical order:<td>n/a<tr><th>Percentages:<td>n/a<tr><th>Animatable:<td>no</table>
<p>This property specifies whether lines of text are laid out horizontally
or vertically and the direction in which blocks progress. Possible
values:</p>
<dl data-dfn-for=writing-mode data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=writing-mode data-dfn-type=value data-export="" id=valuedef-horizontal-tb>horizontal-tb<a class=self-link href=#valuedef-horizontal-tb></a></dfn></dt>
<dd>Top-to-bottom <a data-link-type=dfn href=#block-flow-direction title="block flow direction">block flow direction</a>.
The <a data-link-type=dfn href=#writing-mode0 title="writing mode">writing mode</a> is horizontal.</dd>
<dt><dfn class=css-code data-dfn-for=writing-mode data-dfn-type=value data-export="" id=valuedef-vertical-rl>vertical-rl<a class=self-link href=#valuedef-vertical-rl></a></dfn></dt>
<dd>Right-to-left <a data-link-type=dfn href=#block-flow-direction title="block flow direction">block flow direction</a>.
The <a data-link-type=dfn href=#writing-mode0 title="writing mode">writing mode</a> is vertical.</dd>
<dt><dfn class=css-code data-dfn-for=writing-mode data-dfn-type=value data-export="" id=valuedef-vertical-lr>vertical-lr<a class=self-link href=#valuedef-vertical-lr></a></dfn></dt>
<dd>Left-to-right <a data-link-type=dfn href=#block-flow-direction title="block flow direction">block flow direction</a>.
The <a data-link-type=dfn href=#writing-mode0 title="writing mode">writing mode</a> is vertical.</dd>
</dl>
<p>The <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> property specifies the <a data-link-type=dfn href=#block-flow-direction title="block flow direction">block flow direction</a>,
which determines the progression of block-level boxes in a block formatting
context; the progression of line boxes in a block container that contains
inlines; the progression of rows in a table; etc. By virtue of determining
the stacking direction of line boxes, the <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> property also
determines whether the line boxes' orientation (and thus the <a data-link-type=dfn href=#writing-mode0 title="writing mode">writing mode</a>)
is horizontal or vertical. The <a class=property data-link-type=propdesc href=#propdef-text-orientation title=text-orientation>text-orientation</a> property then determines
how text is laid out within the line box.
<p>The <dfn data-dfn-type=dfn data-export="" id=principal-writing-mode>principal writing mode<a class=self-link href=#principal-writing-mode></a></dfn> of the
document is determined by the <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> and <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> values
specified on the root element. This writing mode is used, for example,
to determine the default page progression direction. (See <a data-biblio-type=informative data-link-type=biblio href=#css3page title=css3page>[CSS3PAGE]</a>.)
Like <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a>, the <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> value of the root element is also
propagated to the initial containing block and sets the block flow
direction of the initial block formatting context.
<p class=note>Note that the <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> property of the HTML BODY
element is <em>not</em> propagated to the viewport. That special
behavior only applies to the background and overflow properties.
<p>If an element has a different block flow direction than its containing
block:
<ul>
<li>If the element has a specified <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visuren.html#propdef-display title=display>display</a> of <span class=css data-link-type=maybe title=inline>inline</span>, its <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visuren.html#propdef-display title=display>display</a>
computes to <span class=css data-link-type=maybe title=inline-block>inline-block</span>. <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>
<li>If the element has a specified <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visuren.html#propdef-display title=display>display</a> of <span class=css data-link-type=maybe title=run-in>run-in</span>, its <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visuren.html#propdef-display title=display>display</a>
computes to <span class=css data-link-type=maybe title=block>block</span>. <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>
<li>If the element is a block container, then it establishes a new block
formatting context.
</ul>
<p>The content of replaced elements do not rotate due to the writing mode:
images, for example, remain upright. However replaced content
involving text (such as MathML content or form elements) should match
the replaced element’s writing mode and line orientation if the UA
supports such a vertical writing mode for the replaced content.
<div class=example>
<p>In the following example, two block elements (1 and 3) separated
by an image (2) are presented in various flow writing modes.</p>
<p>Here is a diagram of horizontal writing mode (<code>writing-mode: horizontal-tb</code>):</p>
<p><img alt="Diagram of horizontal layout: blocks 1, 2, and 3 are stacked top-to-bottom" height=300 src=horizontal.png width=219></p>
<p>Here is a diagram for the right-to-left vertical writing mode commonly
used in East Asia (<code>writing-mode: vertical-rl</code>):</p>
<p><img alt="Diagram of a right-to-left vertical layout: blocks 1, 2,
and 3 are arranged side by side from right to left" height=191 src=vertical-rl.png width=297></p>
<p>And finally, here is a diagram for the left-to-right vertical
writing mode used for Manchu and Mongolian (<code>writing-mode: vertical-lr</code>):</p>
<p><img alt="Diagram of left-to-right vertical layout: blocks 1, 2,
and 3 are arranged side by side from left to right" height=191 src=vertical-lr.png width=300></p>
</div>
<div class=example>
<p>In the following example, some form controls are rendered inside
a block with <a class=css data-link-type=maybe href=#valuedef-vertical-rl title=vertical-rl>vertical-rl</a> writing mode. The form controls are
rendered to match the writing mode.
<pre>&lt;style&gt;
form { writing-mode: vertical-rl; }
&lt;/style&gt;
...
&lt;form&gt;
&lt;p&gt;&lt;label&gt;姓名 &lt;input value="艾俐俐"&gt;&lt;/label&gt;
&lt;p&gt;&lt;label&gt;语文 &lt;select&gt;&lt;option&gt;English
&lt;option&gt;français
&lt;option&gt;فارسی
&lt;option&gt;中文
&lt;option&gt;日本語&lt;/select&gt;&lt;/label&gt;
&lt;/form&gt;</pre>
<p><img alt="Screenshot of vertical layout: the input element is
laid lengthwise from top to bottom and its contents
rendered in a vertical writing mode, matching the
labels outside it. The drop-down selection control
after it slides out to the side (towards the after
edge of the block) rather than downward as it would
in horizontal writing modes." src=vertical-form.png></p>
</div>
<div class=example>
<p>In this example, <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> sets the list markers upright
using the <span class=css data-link-type=maybe title=::marker>::marker</span> pseudo-element. Vertical alignment ensures
that longer numbers will still align with the right of the first
line of text. <a data-biblio-type=informative data-link-type=biblio href=#css3list title=css3list>[CSS3LIST]</a>
<pre>::marker { writing-mode: horizontal-tb;
vertical-align: text-top;
color: blue; }</pre> <div class=figure>
<p><img alt="Diagram showing list markers of '1.', '2.', '3.' sitting
upright atop sideways vertical Latin list item text." class=example src=vertical-horizontal-list-markers.png>
<p class=caption>Example of horizontal list markers in a vertical list</p>
</div>
</div>
<h4 class="heading settled heading" data-level=3.1.1 id=svg-writing-mode><span class=secno>3.1.1 </span><span class=content>
SVG1.1 <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> Values</span><a class=self-link href=#svg-writing-mode></a></h4>
<p>SVG1.1 <a data-biblio-type=normative data-link-type=biblio href=#svg11 title=svg11>[SVG11]</a> defines some additional values: <span class=css data-link-type=maybe title=lr>lr</span>,
<span class=css data-link-type=maybe title=lr-tb>lr-tb</span>, <span class=css data-link-type=maybe title=rl>rl</span>, <span class=css data-link-type=maybe title=rl-tb>rl-tb</span>, <span class=css data-link-type=maybe title=tb>tb</span>, and <span class=css data-link-type=maybe title=tb-rl>tb-rl</span>.
<p>These values are <em>deprecated</em> in any context except SVG1 documents.
Implementations that wish to support these values in the context of CSS
must treat them as follows:
<table class=data>
<thead>
<tr><th>SVG1/Obsolete</th> <th>CSS</tr>
</thead>
<tbody>
<tr><td><span class=css data-link-type=maybe title=lr>lr</span></td> <td rowspan=3><a class=css data-link-type=maybe href=#valuedef-horizontal-tb title=horizontal-tb>horizontal-tb</a></tr>
<tr><td><span class=css data-link-type=maybe title=lr-tb>lr-tb</span></tr>
<tr><td><span class=css data-link-type=maybe title=rl>rl</span></tr>
<tr><td><span class=css data-link-type=maybe title=tb>tb</span></td> <td rowspan=2><a class=css data-link-type=maybe href=#valuedef-vertical-rl title=vertical-rl>vertical-rl</a></tr>
<tr><td><span class=css data-link-type=maybe title=tb-rl>tb-rl</span></tr>
</tbody>
</table>
<p class=note>The SVG1.1 values were also present in an older revision
of the CSS <a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a> specification, which is obsoleted by this
specification. The additional <span class=css data-link-type=maybe title=tb-lr>tb-lr</span> value of that revision is
replaced by <a class=css data-link-type=maybe href=#valuedef-vertical-lr title=vertical-lr>vertical-lr</a>.
<p>In SVG1.1, these values set the <dfn data-dfn-type=dfn data-noexport="" id=inline-progression-direction>inline progression direction<a class=self-link href=#inline-progression-direction></a></dfn>,
in other words, the direction the current text position
advances each time a glyph is added. This is a geometric process that
happens <em>after</em> bidi reordering, and thus has no effect on the
interpretation of the <a class=property data-link-type=propdesc href=#propdef-direction title=direction>direction</a> property (which is independent of
<a class=property data-link-type=propdesc href=#propdef-writing-mode title=writing-mode>writing-mode</a>). (See <a href=http://www.w3.org/TR/SVG/text.html#RelationshipWithBiDirectionality>Relationship
with bidirectionality</a>. <a data-biblio-type=normative data-link-type=biblio href=#svg11 title=svg11>[SVG11]</a>)
<p class=note>There are varying interpretations
on whether this process causes "writing-mode: rl" to merely shift the
text string or reverse the order of all glyphs in the text.</p>
<h2 class="heading settled heading" data-level=4 id=inline-alignment><span class=secno>4 </span><span class=content>
Inline-level Alignment</span><a class=self-link href=#inline-alignment></a></h2>
<p>When different kinds of inline-level content are placed together on a
line, the baselines of the content and the settings of the <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align title=vertical-align>vertical-align</a>
property control how they are aligned in the transverse direction of the
line box. This section discusses what baselines are, how to find them,
and how they are used together with the <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align title=vertical-align>vertical-align</a> property to
determine the alignment of inline-level content.
<h3 class="heading settled heading" data-level=4.1 id=intro-baselines><span class=secno>4.1 </span><span class=content>
Introduction to Baselines</span><a class=self-link href=#intro-baselines></a></h3>
<p><em>This section is non-normative.</em></p>
<p>A <dfn data-dfn-type=dfn data-noexport="" id=baseline>baseline<a class=self-link href=#baseline></a></dfn> is a line along the <a data-link-type=dfn href=#inline-axis- title="inline axis">inline axis</a> of a line box
along which individual glyphs of text are aligned. Baselines guide the
design of glyphs in a font (for example, the bottom of most alphabetic
glyphs typically align with the alphabetic baseline), and they guide
the alignment of glyphs from different fonts or font sizes when typesetting.
<div class=figure>
[Picture of alphabetic text in two font sizes with the baseline and
emboxes indicated.]
</div>
<p>Different writing systems prefer different baseline tables.</p>
<div class=figure>
<p><img alt="Latin prefers the alphabetic baseline, on top of which most
letters rest, though some have descenders that dangle below it.
Indic scripts are sometimes typeset with a hanging baseline,
since their glyph shapes appear to be hanging from a
horizontal line.
Han-based systems, whose glyphs are designed to fill a square,
tend to align on their bottoms." src=script-preferred-baselines.gif></p>
<p class=caption>Preferred baselines in various writing systems</p>
</div>
<p>A well-constructed font contains a <dfn data-dfn-type=dfn data-noexport="" id=baseline-table>baseline table<a class=self-link href=#baseline-table></a></dfn>, which
indicates the position of one or more baselines within the font’s
design coordinate space. (The design coordinate space is scaled with
the font size.)
<div class=figure>
<p><img alt="" src=baselines.gif></p>
<p class=caption>In a well-designed mixed-script font, the glyphs are
positioned in the coordinate space to harmonize with one another
when typeset together. The baseline table is then constructed to
match the shape of the glyphs, each baseline positioned to match
the glyphs from its preferred scripts.</p>
</div>
<p>The baseline table is a property of the font, and the positions
of the various baselines apply to all glyphs in the font.
<p>Different baseline tables can be provided for alignment in
horizontal and vertical text. UAs should use the vertical
tables in vertical writing modes and the horizontal tables
otherwise.
<h3 class="heading settled heading" data-level=4.2 id=text-baselines><span class=secno>4.2 </span><span class=conten 6538 t>
Text Baselines</span><a class=self-link href=#text-baselines></a></h3>
<p>In this specification, only the following baselines are considered:
<dl>
<dt>alphabetic</dt>
<dd>The <dfn data-dfn-type=dfn data-noexport="" id=alphabetic-baseline>alphabetic baseline<a class=self-link href=#alphabetic-baseline></a></dfn>, which typically aligns with the
bottom of uppercase Latin glyphs.
</dd>
<dt>central</dt>
<dd>The <dfn data-dfn-type=dfn data-noexport="" id=central-baseline>central baseline<a class=self-link href=#central-baseline></a></dfn>, which typically crosses the center
of the em box. If the font is missing this baseline,
it is assumed to be halfway between the ascender (<a data-link-type=dfn href=#over title=over>over</a>)
and descender (<a data-link-type=dfn href=#under title=under>under</a>) edges of the em box.
</dd>
</dl>
<p>In vertical writing mode, the <a data-link-type=dfn href=#central-baseline title="central baseline">central baseline</a> is used as the
dominant baseline when <a class=property data-link-type=propdesc href=#propdef-text-orientation title=text-orientation>text-orientation</a> is <a class=css data-link-type=maybe href=#valuedef-mixed title=mixed>mixed</a> or <a class=css data-link-type=maybe href=#valuedef-upright title=upright>upright</a>.
Otherwise the <a data-link-type=dfn href=#alphabetic-baseline title="alphabetic baseline">alphabetic baseline</a> is used.
<p class=note>A future CSS module will deal with baselines in more
detail and allow the choice of other dominant baselines and alignment
options.</p>
<h3 class="heading settled heading" data-level=4.3 id=replaced-baselines><span class=secno>4.3 </span><span class=content>
Atomic Inline Baselines</span><a class=self-link href=#replaced-baselines></a></h3>
<p>If an <a href=http://www.w3.org/TR/CSS21/visuren.html#inline-boxes>atomic
inline</a> (such as an inline-block, inline-table, or replaced inline element)
is not capable of providing its own baseline information, then the
UA synthesizes a baseline table thus:
<dl>
<dt>alphabetic</dt>
<dd>The alphabetic baseline is assumed to be at the <a data-link-type=dfn href=#under title=under>under</a>
margin edge.</dd>
<dt>central</dt>
<dd>The central baseline is assumed to be halfway between the
<a data-link-type=dfn href=#under title=under>under</a> and <a data-link-type=dfn href=#over title=over>over</a> margin edges of the box.
</dl>
<h3 class="heading settled heading" data-level=4.4 id=baseline-alignment><span class=secno>4.4 </span><span class=content>
Baseline Alignment</span><a class=self-link href=#baseline-alignment></a></h3>
<p>The <dfn data-dfn-type=dfn data-noexport="" id=dominant-baseline>dominant baseline<a class=self-link href=#dominant-baseline></a></dfn>