8000 csswg-drafts/css-ruby/Overview.html at c90c753508a191de3b00a9e6789c0a57d4dac076 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
1791 lines (1533 loc) · 135 KB

File metadata and controls

1791 lines (1533 loc) · 135 KB
</div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2014 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=abstract><span class=content>Abstract</span></h2>
<div class=p-summary data-fill-with=abstract><p>“Ruby”, a form of interlinear annotation, are short runs of text alongside the base text.
They are typically used in East Asian documents to indicate pronunciation or to provide a short annotation.
This module describes the rendering model and formatting controls related to displaying ruby annotations in CSS.</p>
<a href=http://www.w3.org/TR/CSS/>CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-ruby%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href=http://www.w3.org/Mail/Request>instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-ruby” in the subject,
preferably like this:
“[css-ruby] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=http://www.w3.org/Style/CSS/members>CSS Working Group</a>
(part of the <a href=http://www.w3.org/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc>
<li><a href=#intro><span class=secno>1</span> Introduction</a>
<ul class=toc>
<li><a href=#placement><span class=secno>1.1</span> Module interactions</a>
<li><a href=#values><span class=secno>1.2</span> Values</a>
<li><a href=#diagram-conventions><span class=secno>1.3</span> Diagram conventions</a>
<li><a href=#ruby-def><span class=secno>1.4</span> What is ruby?</a></ul>
<li><a href=#ruby-model><span class=secno>2</span> Ruby Box Model</a>
<ul class=toc>
<li><a href=#ruby-display><span class=secno>2.1</span> Ruby-specific <span class=property data-link-type=propdesc title=display>display</span> Values</a>
<ul class=toc>
<li><a href=#formatting-context><span class=secno>2.1.1</span> The Ruby Formatting Context</a>
<li><a href=#display-inside-outside><span class=secno>2.1.2</span> Ruby-specific <span class=property data-link-type=propdesc title=display-inside>display-inside</span> and <span class=property data-link-type=propdesc title=display-outside>display-outside</span> values</a>
<li><a href=#block-ruby><span class=secno>2.1.3</span> Non-Inline Ruby</a></ul>
<li><a href=#box-fixup><span class=secno>2.2</span> Anonymous Ruby Box Generation</a>
<li><a href=#ruby-pairing><span class=secno>2.3</span> Annotation Pairing</a>
<ul class=toc>
<li><a href=#segment-pairing><span class=secno>2.3.1</span> Segment Pairing and Annotation Levels</a>
<li><a href=#base-annotation-pairing><span class=secno>2.3.2</span> Unit Pairing and Spanning Annotations</a>
<li><a href=#nested-pairing><span class=secno>2.3.3</span> Complex Spanning with Nested Ruby</a></ul>
<li><a href=#autohide><span class=secno>2.4</span> Autohiding Base-identical Annotations</a>
<li><a href=#white-space><span class=secno>2.5</span> White Space Collapsing</a></ul>
<li><a href=#ruby-layout><span class=secno>3</span> Ruby Layout</a>
<ul class=toc>
<li><a href=#inter-character-layout><span class=secno>3.1</span> Inter-character Ruby Layout</a>
<li><a href=#box-style><span class=secno>3.2</span> Styling Ruby Boxes</a>
<li><a href=#line-breaks><span class=secno>3.3</span> Breaking Across Lines</a>
<ul class=toc>
<li><a href=#break-between><span class=secno>3.3.1</span> Breaking Between Bases</a>
<li><a href=#break-within><span class=secno>3.3.2</span> Breaking Within Bases</a></ul>
<li><a href=#bidi><span class=secno>3.4</span> Bidi Reordering</a>
<li><a href=#line-height><span class=secno>3.5</span> Line Spacing</a></ul>
<li><a href=#ruby-props><span class=secno>4</span> Ruby Formatting Properties</a>
<ul class=toc>
<li><a href=#rubypos><span class=secno>4.1</span> Ruby Positioning: the <span class=property data-link-type=propdesc title=ruby-position>ruby-position</span> property</a>
<li><a href=#collapsed-ruby><span class=secno>4.2</span> Sharing Annotation Space: the <span class=property data-link-type=propdesc title=ruby-merge>ruby-merge</span> property</a>
<li><a href=#ruby-align-property><span class=secno>4.3</span> <span></span> Ruby Text Distribution: the <span class=property data-link-type=propdesc title=ruby-align>ruby-align</span> property</a></ul>
<li><a href=#edge-effects><span class=secno>5</span> Edge Effects</a>
<ul class=toc>
<li><a href=#ruby-overhang><span class=secno>5.1</span> Overhanging Ruby</a>
<li><a href=#line-edge><span class=secno>5.2</span> Line-edge Alignment</a></ul>
<li><a href=#default-stylesheet><span class=secno></span> Appendix A: Default Style Sheet</a>
<ul class=toc>
<li><a href=#default-ua-ruby><span class=secno></span> <span class=secno>A.1</span> Supporting Ruby Layout</a>
<li><a href=#default-inline><span class=secno></span> <span class=secno>A.2</span> Inlining Ruby Annotations</a>
<li><a href=#default-parens><span class=secno></span> <span class=secno>A.3</span> Generating Parentheses</a></ul>
<li><a href=#glossary><span class=secno>6</span> Glossary</a>
<li><a href=#acknowledgments><span class=secno></span> Acknowledgments</a>
<li><a href=#changes><span class=secno></span> Changes</a>
<li><a href=#conformance><span class=secno></span> Conformance</a>
<ul class=toc>
<li><a href=#conventions><span class=secno></span> Document conventions</a>
<li><a href=#conformance-classes><span class=secno></span> Conformance classes</a>
<li><a href=#partial><span class=secno></span> Partial implementations</a>
<li><a href=#experimental><span class=secno></span> Experimental implementations</a>
<li><a href=#testing><span class=secno></span> Non-experimental implementations</a></ul>
<li><a href=#references><span class=secno></span> References</a>
<ul class=toc>
<li><a href=#normative><span class=secno></span> Normative References</a>
<li><a href=#informative><span class=secno></span> Informative References</a></ul>
<li><a href=#index><span class=secno></span> Index</a>
<li><a href=#property-index><span class=secno></span> Property index</a>
<li><a href=#issues-index><span class=secno></span> Issues Index</a></ul></div>
<p></p>
<h2 class="heading settled heading" data-level=1 id=intro><span class=secno>1 </span><span class=content>
Introduction</span><a class=self-link href=#intro></a></h2>
<p><em>This section is not normative.</em>
<h3 class="heading settled heading" data-level=1.1 id=placement><span class=secno>1.1 </span><span class=content>
Module interactions</span><a class=self-link href=#placement></a></h3>
<p>This module extends the inline box model of CSS Level 2 <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-CSS21>[CSS21]</a>
to support ruby.
<p>None of the properties in this module apply to the <code>::first-line</code> or
<code>::first-letter</code> pseudo-elements.
<h3 class="heading settled heading" data-level=1.2 id=values><span class=secno>1.2 </span><span class=content>
Values</span><a class=self-link href=#values></a></h3>
<p>This specification follows the
<a href=http://www.w3.org/TR/CSS21/about.html#property-defs>CSS property
definition conventions</a> from <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-CSS21>[CSS21]</a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-CSS21>[CSS21]</a>.
Other CSS modules may expand the definitions of these value types: for
example <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3val title=biblio-CSS3VAL>[CSS3VAL]</a>, when combined with this module, expands the
definition of the <var>&lt;length&gt;</var> value type as used in this specification.</p>
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the
<a href=http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit>inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h3 class="heading settled heading" data-level=1.3 id=diagram-conventions><span class=secno>1.3 </span><span class=content>
Diagram conventions</span><a class=self-link href=#diagram-conventions></a></h3>
<p>Many typographical conventions in East Asian typography depend
on whether the character rendered is wide (CJK) or narrow (non-CJK).
There are a number of illustrations in this document
for which the following legend is used:
<dl>
<dt><img alt="Symbolic wide-cell glyph representation" height=39 src=images/fullwidth.gif width=39>
<dd>Wide-cell glyph (e.g. Han) that is the <var>n</var>th character in the text run.
They are typically sized to 50% when used as annotations.
<dt><img alt="Symbolic narrow-cell glyph representation" height=39 src=images/halfwidth.gif width=19>
<dd>Narrow-cell glyph (e.g. Roman) which is the <var>n</var>th glyph in the text run.
</dl>
<p>The orientation which the above symbols assume in the diagrams
corresponds to the orientation that the glyphs they represent
are intended to assume when rendered by the user agent.
Spacing between these characters in the diagrams is incidental,
unless intentionally changed to make a point.
<h3 class="heading settled heading" data-level=1.4 id=ruby-def><span class=secno>1.4 </span><span class=content>
What is ruby?</span><a class=self-link href=#ruby-def></a></h3>
<p><dfn data-dfn-type=dfn data-noexport="" id=ruby>Ruby<a class=self-link href=#ruby></a></dfn> is the commonly-used name for a run of text
that appears alongside another run of text (referred to as the “base”)
and serves as an annotation or a pronunciation guide associated with that run of text.
<p>The following figures show two examples of Ruby,
a simple case and one with more complicated structure.
<div class=example>
<p>In this first example, a single annotation is used to annotate the base text.
<div class=figure>
<p><img alt="Example of ruby applied on top of a Japanese expression" src=images/licence.png>
<p class=caption>Example of ruby used in Japanese (simple case)
</div>
<p>In Japanese typography, this case is sometimes called
<span lang=ja>taigo</span> ruby or group-ruby (per-word ruby),
because the annotation as a whole is associated
with multi-character word (as a whole).
</div>
<div class=example>
<p>In this second example,
two levels of annotations are attached to a base sequence:
the hiragana characters on top refer to the pronunciation of each of the base kanji characters,
while the words “Keio” and “University” on the bottom are annotations describing the English translation.
<div class=figure>
<p><img alt="Example showing complex ruby with annotation text over and under the base characters" src=images/ruby-univ.gif>
<p class=caption>Complex ruby with annotation text over and under the base characters
</div>
<p>
<p>Notice that to allow correct association between the hiragana characters and
their corresponding Kanji base characters,
the spacing between these Kanji characters is adjusted.
(This happens around the fourth Kanji character in the figure above.)
To avoid variable spacing between the Kanji characters in the example above
the hiragana annotations can be styled as a <a data-link-type=dfn href=#collapsed-annotation title="collapsed annotation">collapsed annotation</a>,
which will look more like the group-ruby example earlier.
However because the base-annotation pairings are recorded in the ruby structure,
if the text breaks across lines, the annotation characters will stay
correctly paired with their respective base characters.
</div>
<p><a data-link-type=dfn href=#ruby title=Ruby>Ruby</a> formatting as used in Japanese is described in JIS X-4051 <a data-biblio-type=informative data-link-type=biblio href=#biblio-jis4051 title=biblio-JIS4051>[JIS4051]</a> (in Japanese)
and in Requirements for Japanese Text Layout <a data-biblio-type=informative data-link-type=biblio href=#biblio-jlreq title=biblio-JLREQ>[JLREQ]</a> (in English and Japanese)].
In HTML, ruby structure and markup to represent it is described
in the Ruby Markup Extension specification.
This module describes the CSS rendering model
and formatting controls relevant to ruby layout of such markup.
<h2 class="heading settled heading" data-level=2 id=ruby-model><span class=secno>2 </span><span class=content>
Ruby Box Model</span><a class=self-link href=#ruby-model></a></h2>
<p>The CSS ruby model is based on
the <a href=http://darobin.github.io/html-ruby/>HTML Ruby Markup Extension</a>
and <a href=http://www.w3.org/TR/ruby/>XHTML Ruby Annotation Recommendation</a> <a data-biblio-type=informative data-link-type=biblio href=#biblio-ruby title=biblio-RUBY>[RUBY]</a>.
In this model, a ruby structure consists of
one or more <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> elements representing the base (annotated) text,
associated with one or more levels of <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> elements representing the annotations.
The structure of ruby is similar to that of a table:
there are “rows” (the <a data-link-type=dfn href=#base-level title="base level">base text level</a>, each <a data-link-type=dfn href=#annotation-level title="annotation level">annotation level</a>)
and “columns” (each <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> and its corresponding <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>).
<p>Consecutive bases and annotations are grouped together into <a data-link-type=dfn href=#ruby-segments title="ruby segments">ruby segments</a>.
Within a <a data-link-type=dfn href=#ruby-segments title="ruby segment">ruby segment</a>, a <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> may span multiple <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
<p class=note>In HTML, a single <code>&lt;ruby&gt;</code> element may contain multiple <a data-link-type=dfn href=#ruby-segments title="ruby segments">ruby segments</a>.
(In the XHTML Ruby model, a single <code>&lt;ruby&gt;</code> element can only contain one <a data-link-type=dfn href=#ruby-segments title="ruby segment">ruby segment</a>.)
<h3 class="heading settled heading" data-level=2.1 id=ruby-display><span class=secno>2.1 </span><span class=content>
Ruby-specific <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> Values</span><a class=self-link href=#ruby-display></a></h3>
<p>For document languages (such as XML applications) that do not have pre-defined ruby elements,
authors must map document language elements to ruby elements;
this is done with the <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> property.
<table class=propdef>
<tr>
<th>Name:
<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-display>display<a class=self-link href=#propdef-display></a></dfn><tr>
<th><a href=#values>New Values</a>:
<td>ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container
</table>
<p>The following new <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> values assign ruby layout roles to an arbitrary element:
<dl data-dfn-for=display>
<dt><a class=css data-link-type=maybe href=#ruby title=ruby>ruby</a>
<dd>Specifies that an element generates a <dfn data-dfn-type=dfn data-noexport="" id=ruby-container title="ruby container | ruby container box">ruby container box<a class=self-link href=#ruby-container></a></dfn>.
(Corresponds to HTML/XHTML <code>&lt;ruby&gt;</code> elements.)
<dt><span class=css data-link-type=maybe title=ruby-base>ruby-base</span>
<dd>Specifies that an element generates a <dfn data-dfn-type=dfn data-noexport="" id=ruby-base-box title="ruby base box | ruby base">ruby base box<a class=self-link href=#ruby-base-box></a></dfn>.
(Corresponds to HTML/XHTML <code>&lt;rb&gt;</code> elements.)
<dt><span class=css data-link-type=maybe title=ruby-text>ruby-text</span>
<dd>Specifies that an element generates a <dfn data-dfn-type=dfn data-noexport="" id=ruby-annotation-box title="ruby annotation box | ruby annotation | annotation">ruby annotation box<a class=self-link href=#ruby-annotation-box></a></dfn>.
(Corresponds to HTML/XHTML <code>&lt;rt&gt;</code> elements.)
<dt><span class=css data-link-type=maybe title=ruby-base-container>ruby-base-container</span>
<dd>Specifies that an element generates a <dfn data-dfn-type=dfn data-noexport="" id=ruby-base-container-box title="ruby base container box | ruby base container">ruby base container box<a class=self-link href=#ruby-base-container-box></a></dfn>.
(Corresponds to XHTML <code>&lt;rbc&gt;</code> elements; generated as an anonymous box in HTML.)
<dt><span class=css data-link-type=maybe title=ruby-text-container>ruby-text-container</span>
<dd>Specifies that an element generates a <dfn data-dfn-type=dfn data-noexport="" id=ruby-annotation-container-box title="ruby annotation container box | ruby annotation container">ruby annotation container box<a class=self-link href=#ruby-annotation-container-box></a></dfn>.
(Corresponds to HTML/XHTML <code>&lt;rtc&gt;</code> elements.)
</dl>
<p class=advisement>Authors using a language (such as HTML)
that supports dedicated ruby markup
should use that markup rather than
styling arbitrary elements (like <code>&lt;span&gt;</code>)
with ruby <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> values.
Using the correct markup ensures that screen readers
and non-CSS renderers can interpret the ruby structures.
<h4 class="heading settled heading" data-level=2.1.1 id=formatting-context><span class=secno>2.1.1 </span><span class=content>
The Ruby Formatting Context</span><a class=self-link href=#formatting-context></a></h4>
<p><a data-link-type=dfn href=#ruby-container title="Ruby containers">Ruby containers</a> are non-atomic inline-level boxes.
Like inline boxes, they break across lines,
and their containing block is the nearest block container ancestor.
And just as the contents of an inline box
participate in the same inline formatting context that contains the inline box itself,
a <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> and its base-level contents
participate in the same inline formatting context that contains the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> itself.
<p>However <a data-link-type=dfn href=#ruby-container title="ruby containers">ruby containers</a> also establish a <dfn data-dfn-type=dfn data-noexport="" id=ruby-formatting-context>ruby formatting context<a class=self-link href=#ruby-formatting-context></a></dfn>
that builds further structure around their segment of the inline formatting context.
<a data-link-type=dfn href=#ruby-base-box title="Ruby bases">Ruby bases</a>, <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>, <a data-link-type=dfn href=#ruby-base-container-box title="ruby base containers">ruby base containers</a>, and <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a>
are <dfn data-dfn-type=dfn data-noexport="" id=internal-ruby-boxes title="internal ruby boxes|internal ruby display types">internal ruby boxes<a class=self-link href=#internal-ruby-boxes></a></dfn>:
like <i data-link-type=dfn title="internal table elements">internal table elements</i>,
they have specific roles in ruby layout,
and participate in their <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>’s <a data-link-type=dfn href=#ruby-formatting-context title="ruby formatting context">ruby formatting context</a>.
<p>As with the contents of inline boxes,
the containing block for the contents of a <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> (and all its <a data-link-type=dfn href=#internal-ruby-boxes title="internal ruby boxes">internal ruby boxes</a>)
is the containing block of the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>.
So floats, for example, are trapped by the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>’s containing block,
not any of the ruby box types.
<p class=issue id=issue-ca88244c><a class=self-link href=#issue-ca88244c></a>Are internal ruby boxes inline-level?
<h4 class="heading settled heading" data-level=2.1.2 id=display-inside-outside><span class=secno>2.1.2 </span><span class=content>
Ruby-specific <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside title=display-inside>display-inside</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside title=display-outside>display-outside</a> values</span><a class=self-link href=#display-inside-outside></a></h4>
<p>The ruby-specific <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> values map to <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside title=display-inside>display-inside</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside title=display-outside>display-outside</a> as follows:
<table class=data>
<thead>
<tr><th><a class=property data-link-type=propdesc href=#propdef-display title=display>display</a>
<th><a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside title=display-inside>display-inside</a>
<th><a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside title=display-outside>display-outside</a>
<tbody>
<tr><td><a class=css data-link-type=maybe href=#ruby title=ruby>ruby</a>
<td><span class=css data-link-type=maybe title=inline-level>inline-level</span>
<td><a class=css data-link-type=maybe href=#ruby title=ruby>ruby</a>
<tr><td><span class=css data-link-type=maybe title=ruby-base>ruby-base</span>
<td><span class=css data-link-type=maybe title=ruby-base>ruby-base</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<tr><td><span class=css data-link-type=maybe title=ruby-text>ruby-text</span>
<td><span class=css data-link-type=maybe title=ruby-text>ruby-text</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<tr><td><span class=css data-link-type=maybe title=ruby-base-container>ruby-base-container</span>
<td><span class=css data-link-type=maybe title=ruby-base-container>ruby-base-container</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
<tr><td><span class=css data-link-type=maybe title=ruby-text-container>ruby-text-container</span>
<td><span class=css data-link-type=maybe title=ruby-text-container>ruby-text-container</span>
<td><span class=css data-link-type=maybe title=auto>auto</span>
</table>
<p>See the <a href=http://www.w3.org/TR/css-display/>CSS Display Module</a>
for more information on <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside title=display-inside>display-inside</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside title=display-outside>display-outside</a>. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-display title=biblio-CSS3-DISPLAY>[CSS3-DISPLAY]</a>
<h4 class="heading settled heading" data-level=2.1.3 id=block-ruby><span class=secno>2.1.3 </span><span class=content>
Non-Inline Ruby</span><a class=self-link href=#block-ruby></a></h4>
<p>If an element has a computed <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside title=display-inside>display-inside</a> of <a class=css data-link-type=maybe href=#ruby title=ruby>ruby</a>
and a computed <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside title=display-outside>display-outside</a> other than <span class=css data-link-type=maybe title=inline-level>inline-level</span>,
then it generates two boxes:
a principal block container box of the required <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside title=display-outside>display-outside</a> type,
and an inline-level <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>.
All properties specified on the element apply to the principal box
(and if inheritable, inherit to the <a data-link-type=dfn href=#ruby-container title="ruby container box">ruby container box</a>).
This allows styling the element as a block,
while correctly maintaining the internal ruby structure.
<p>
Note: There is no dedicated block-level <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> shorthand keyword
because ruby is fundamentally an inline layout feature.
<p>Absolute positioning or floating an element causes its <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> value
to compute to a block-level equivalent. (See <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-CSS21>[CSS21]</a> section 9.7.)
This is equivalent to setting its <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside title=display-outside>display-outside</a> to <span class=css data-link-type=maybe title=block-level>block-level</span>.
For the <a data-link-type=dfn href=#internal-ruby-boxes title="internal ruby display types">internal ruby display types</a>,
this causes their <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> value to compute to <span class=css data-link-type=maybe title=block>block</span>.
<span class=issue id=issue-47ce3bc6><a class=self-link href=#issue-47ce3bc6></a>This should go into the Display module. Once that’s done, this can become a note.</span>
<h3 class="heading settled heading" data-level=2.2 id=box-fixup><span class=secno>2.2 </span><span class=content>
Anonymous Ruby Box Generation</span><a class=self-link href=#box-fixup></a></h3>
<p>The CSS model does not require that the document language
include elements that correspond to each of these components.
Missing parts of the structure are implied through the anonymous box generation rules
<a href=http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes>similar to those used to normalize tables</a>. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-CSS21>[CSS21]</a>
<ol>
<li id=anon-gen-anon-ruby><a class=self-link href=#anon-gen-anon-ruby></a><strong>Generate anonymous ruby containers</strong>:
Any <a href=http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes>consecutive</a> sequence of
improperly-contained
<a data-link-type=dfn href=#ruby-base-container-box title="ruby base containers">ruby base containers</a>,
<a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a>,
<a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>,
and/or
<a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>
(and any intervening <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#white-space title="white space">white space</a>)
is wrapped in an anonymous <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>.
For the purpose of this step:
<ul>
<li>an improperly-contained <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> is one not parented by a <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> or <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>
<li>an improperly-contained <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> is one not parented by a <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a> or <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>
<li>an improperly-contained <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> or <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>
is one not parented by a <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>
</ul>
<li id=anon-gen-inlinize><a class=self-link href=#anon-gen-inlinize></a><strong>Inlinize block-level boxes:</strong>
Any in-flow block-level boxes directly contained by a
<a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>,
<a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>,
<a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>,
<a data-link-type=dfn href=#ruby-base-box title="ruby base box">ruby base box</a>,
or <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation box">ruby annotation box</a>
are forced to be inline-level boxes,
and their <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> value computed accordingly.
For example,
the <a class=property data-link-type=propdesc href=#propdef-display title=display>display</a> property of an in-flow element with <a class=css data-link-type=propdesc href=#propdef-display title=display>display: block</a>
parented by an element with <a class=css data-link-type=propdesc href=#propdef-display title=display>display: ruby-text</a>
computes to <span class=css data-link-type=maybe title=inline-block>inline-block</span>.
This computation occurs after any intermediary anonymous-box fixup
(such as that required by internal table elements).
<li id=anony-gen-trim-space><a class=self-link href=#anony-gen-trim-space></a><strong>Trim leading/trailing white space:</strong>
Any white space within a ruby structure is discarded
at the beginning and end of
a <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>, <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>, or <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>.
<li id=anon-gen-bare-inlines><a class=self-link href=#anon-gen-bare-inlines></a><strong>Wrap misparented inline-level content:</strong>
Any consecutive sequence of text and inline-level boxes
directly parented by a <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> or <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
is wrapped in an anonymous <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>.
Similarly, any consecutive sequence of text and inline-level boxes
directly parented by a <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>
is wrapped in an anonymous <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>.
<p>However, if an anonymous box so constructed contains only <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#white-space title="white space">white space</a>,
it is considered <dfn data-dfn-type=dfn data-noexport="" id=intra-ruby-white-space>intra-ruby white space<a class=self-link href=#intra-ruby-white-space></a></dfn>
and is either discarded as <a data-link-type=dfn href=#inter-level-white-space title="inter-level white space">inter-level white space</a>
or preserved as <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a>
as described below.</p>
<li id=anon-gen-discard-space><a class=self-link href=#anon-gen-discard-space></a><strong>Remove inter-level white space:</strong>
Any <a data-link-type=dfn href=#intra-ruby-white-space title="intra-ruby white space">intra-ruby white space</a>
whose immediately adjacent siblings match one of the patterns below
is <dfn data-dfn-type=dfn data-noexport="" id=inter-level-white-space>inter-level white space<a class=self-link href=#inter-level-white-space></a></dfn>
and is removed, as if it had <a class=css data-link-type=propdesc href=#propdef-display title=display>display: none</a>.
<table class=data>
<thead>
<tr><th>Previous box
<th>Next box
<tbody>
<tr><td><var>any</var>
<td><a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>
<tr><td>not <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>
<td><a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>
</table>
<li id=anon-gen-interpret-space><a class=self-link href=#anon-gen-interpret-space></a><strong>Interpret intra-level white space:</strong>
Any <a data-link-type=dfn href=#intra-ruby-white-space title="intra-ruby white space">intra-ruby white space</a> box
whose immediately adjacent siblings match one of the patterns below
is assigned the box type and subtype defined in the table below:
<table class=data>
<colgroup span=2></colgroup>
<colgroup span=2></colgroup>
<thead>
<tr><th>Previous box
<th>Next box
<th>Box type
<th>Subtype
<tbody>
<tr><td><a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>
<td><a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>
<td><a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>
<td><dfn data-dfn-type=dfn data-noexport="" id=inter-base-white-space>inter-base white space<a class=self-link href=#inter-base-white-space></a></dfn>
<tr><td><a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>
<td><a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>
<td><a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>
<td><dfn data-dfn-type=dfn data-noexport="" id=inter-annotation-white-space>inter-annotation white space<a class=self-link href=#inter-annotation-white-space></a></dfn>
<tr><td><a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> or <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>
<td><a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> or <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
<td rowspan=3><a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>
<td rowspan=3><dfn data-dfn-type=dfn data-noexport="" id=inter-segment-white-space>inter-segment white space<a class=self-link href=#inter-segment-white-space></a></dfn>
<tr><td><a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> or <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
<td><a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
<tr><td><a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
<td><a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
</table>
The <dfn data-dfn-type=dfn data-noexport="" id=intra-level-white-space>intra-level white space<a class=self-link href=#intra-level-white-space></a></dfn> boxes defined above are
treated specially for pairing and layout. See below.
<li id=anon-gen-unbreak><a class=self-link href=#anon-gen-unbreak></a><strong>Suppress line breaks:</strong>
Convert all forced line breaks inside <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> (regardless of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-white-space title=white-space>white-space</a> value)
as defined for <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#collapsible-white-space title=collapsible>collapsible</a> segment breaks in <a href=http://www.w3.org/TR/css-text-3/#line-break-transform>CSS Text Level 3 § 4.1.2</a>.
<p class=issue id=issue-8af70305><a class=self-link href=#issue-8af70305></a>The goal of this is to simplify the layout model by suppressing any line breaks within ruby annotations.
Alternatively we could try to define some kind of acceptable behavior for them.
<li id=anon-gen-anon-containers><a class=self-link href=#anon-gen-anon-containers></a><strong>Generate anonymous level containers:</strong>
Any consecutive sequence of <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> and <a data-link-type=dfn href=#inter-base-white-space title="inter-base white space">inter-base white space</a>
(and not <a data-link-type=dfn href=#inter-segment-white-space title="inter-segment white space">inter-segment white space</a>)
not parented by a <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
is wrapped in an anonymous <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>.
Similarly, any consecutive sequence of <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> and <a data-link-type=dfn href=#inter-annotation-white-space title="inter-annotation white space">inter-annotation white space</a>
not parented by a <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>
is wrapped in an anonymous <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>.
</ol>
<p class=issue id=issue-778a7acd><a class=self-link href=#issue-778a7acd></a>Make <a href=http://lists.w3.org/Archives/Public/www-archive/2014Jun/att-0027/PastedGraphic-1.png>this diagram</a> into an example.
<p>Once all ruby layout structures are properly parented,
the UA can start to associate bases with their annotations.
<p class=note>
Note that the UA is not required to create any of these anonymous boxes
(or the anonymous empty <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a> boxes in the pairing section)
in its internal structures,
as long as pairing and layout behaves as if they existed.
<h3 class="heading settled heading" data-level=2.3 id=ruby-pairing><span class=secno>2.3 </span><span class=content>
Annotation Pairing</span><a class=self-link href=#ruby-pairing></a></h3>
<p>Annotation <dfn data-dfn-type=dfn data-noexport="" id=pairing>pairing<a c 8096 lass=self-link href=#pairing></a></dfn> is the process of associating
<a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> with <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
Each <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> is associated with one or more <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>,
and is said to <dfn data-dfn-type=dfn data-noexport="" id=span>span<a class=self-link href=#span></a></dfn> those bases.
(A <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> that <a data-link-type=dfn href=#span title=spans>spans</a> multiple bases is called
a <dfn data-dfn-type=dfn data-noexport="" id=spanning-annotation>spanning annotation<a class=self-link href=#spanning-annotation></a></dfn>.)
<p>A <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> is can be associated with
only one <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> per <a data-link-type=dfn href=#annotation-level title="annotation level">annotation level</a>.
However, if there are multiple <a data-link-type=dfn href=#annotation-level title="annotation levels">annotation levels</a>,
it can be associated with multiple <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>.</p>
<p>Once pairing is complete, ruby “column” units are defined,
each represented by a single <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>
and one <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> (possibly an empty, anonymous one)
from each <a data-link-type=dfn href=#annotation-level title="annotation level">annotation level</a> in its <a data-link-type=dfn href=#ruby-segments title="ruby segment">ruby segment</a>.</p>
<h4 class="heading settled heading" data-level=2.3.1 id=segment-pairing><span class=secno>2.3.1 </span><span class=content>
Segment Pairing and Annotation Levels</span><a class=self-link href=#segment-pairing></a></h4>
<p>A ruby structure is divided into <dfn data-dfn-type=dfn data-noexport="" id=ruby-segments>ruby segments<a class=self-link href=#ruby-segments></a></dfn>,
each consisting of a single <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
followed by one or more <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a>.
Each <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a> in a <a data-link-type=dfn href=#ruby-segments title="ruby segment">ruby segment</a>
represents one <dfn data-dfn-type=dfn data-noexport="" id=annotation-level title="annotation level | level">level<a class=self-link href=#annotation-level></a></dfn> of annotation for the base text:
the first one represents the first level of annotation,
the second one represents the second level of annotation,
and so on.
The <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> represents the <dfn data-dfn-type=dfn data-noexport="" id=base-level>base level<a class=self-link href=#base-level></a></dfn>.
The <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> in each segment is thus paired
with each of the <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a> in that segment.
<p>In order to handle degenerate cases, some empty anonymous containers are assumed:
<ul>
<li>If the first child of a <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> is a <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>,
an anonymous, empty <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> is assumed to exist before it.
<li>Similarly, if the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> contains consecutive <a data-link-type=dfn href=#ruby-base-container-box title="ruby base containers">ruby base containers</a>,
anonymous, empty <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a> are assumed to exist between them.
</ul>
<p><a data-link-type=dfn href=#inter-segment-white-space title="Inter-segment white space">Inter-segment white space</a> is effectively a <a data-link-type=dfn href=#ruby-segments title="ruby segment">ruby segment</a> of its own.
<h4 class="heading settled heading" data-level=2.3.2 id=base-annotation-pairing><span class=secno>2.3.2 </span><span class=content>
Unit Pairing and Spanning Annotations</span><a class=self-link href=#base-annotation-pairing></a></h4>
<p>Within a <a data-link-type=dfn href=#ruby-segments title="ruby segment">ruby segment</a>,
each <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> in the <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>
is paired with one <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>
from each <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a> in its <a data-link-type=dfn href=#ruby-segments title="ruby segment">ruby segment</a>.
<p>If there are not enough <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> in a <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>,
the last one is paired with (<a data-link-type=dfn href=#span title=spans>spans</a> across) any excess <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
(If there are not any in the <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>,
an anonymous empty one is assumed to exist.)
If there are not enough <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>,
any remaining <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> pair with empty, anonymous bases
inserted at the end of the <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>.
<p>If an implementation supports ruby markup with explicit spanning
(e.g. XHTML Complex Ruby Annotations),
it must adjust the pairing rules to pair <a data-link-type=dfn href=#spanning-annotation title="spanning annotations">spanning annotations</a>
to their bases appropriately.
<p><a data-link-type=dfn href=#intra-level-white-space title="Intra-level white space">Intra-level white space</a> does not participate in standard annotation <a data-link-type=dfn href=#pairing title=pairing>pairing</a>.
However, if the immediately-adjacent <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> or <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>
are paired
<ul>
<li>with two <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> or <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">annotations</a>
that surround corresponding <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a> in another level,
then the so-corresponding <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a> boxes are also paired.
<li>with a single spanning <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>,
then the <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a> is also paired to that <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a>
<li>with two <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> or <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">annotations</a>
with no intervening <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a>,
then the <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a> box pairs with
an anonymous empty <a data-link-type=dfn href=#intra-level-white-space title="intra-level white space">intra-level white space</a> box assumed to exist between them.
</ul>
<p class=issue id=issue-0230a91a><a class=self-link href=#issue-0230a91a></a>Insert diagram</p>
<h4 class="heading settled heading" data-level=2.3.3 id=nested-pairing><span class=secno>2.3.3 </span><span class=content>
Complex Spanning with Nested Ruby</span><a class=self-link href=#nested-pairing></a></h4>
<p><dfn data-dfn-type=dfn data-noexport="" id=nested-ruby title="nested ruby"><a class=self-link href=#nested-ruby></a></dfn>When <a data-link-type=dfn href=#ruby-container title="ruby containers">ruby containers</a> are nested,
pairing begins with the deepest <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>,
then expands out.
From the pairing perspective of the outer <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>,
each <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> nested within another <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>
counts as representing a single <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>/<a data-link-type=dfn href=#ruby-annotation-box title=annotation>annotation</a> per level.
The outer <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>’s <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> paired to the <a data-link-type=dfn href=#nested-ruby title="nested ruby">nested ruby</a>
are therefore paired with (and <a data-link-type=dfn href=#span title=span>span</a>) all of the nested <a data-link-type=dfn href=#ruby-container title="ru 22BE by container">ruby container</a>’s <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
Each <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a> in the nested <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>
occupies the same <a data-link-type=dfn href=#annotation-level title="annotation level">annotation level</a> in the outer <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>
as it does in the inner one
and participates in its layout as if it were directly contained in the outer <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>.
<p>This process is recursive.
Thus, using nested <a data-link-type=dfn href=#ruby-container title="ruby containers">ruby containers</a> allows the representation
of complex spanning relationships.
<p class=issue id=issue-9b177ca3><a class=self-link href=#issue-9b177ca3></a>It’s not clear whether this falls out of layout handling of ruby containers inside ruby bases
or needs to be handled specially.
Waiting until layout is better-defined to find out...
<h3 class="heading settled heading" data-level=2.4 id=autohide><span class=secno>2.4 </span><span class=content>
Autohiding Base-identical Annotations</span><a class=self-link href=#autohide></a></h3>
<p>If a <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> has the exact same text content as its base,
it is <dfn data-dfn-type=dfn data-noexport="" id=hidden-ruby-annotation title="hidden ruby annotation | hidden annotation">hidden<a class=self-link href=#hidden-ruby-annotation></a></dfn>.
Hiding a <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> does not affect annotation pairing
or the block-axis positioning of boxes in other <a data-link-type=dfn href=#annotation-level title=levels>levels</a>.
However the <a data-link-type=dfn href=#hidden-ruby-annotation title="hidden annotation">hidden annotation</a> is not visible,
and it has no impact on layout
other than to separate adjacent sequences of <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation boxes">ruby annotation boxes</a> within its level,
as if they belonged to separate segments
and the <a data-link-type=dfn href=#hidden-ruby-annotation title="hidden annotation">hidden annotation</a>’s base were not a <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> but an intervening inline.
<div class=example>
<p>This is to allow correct inlined display of annotations
for Japanese words that are a mix of kanji and hiragana.
For example, the word <span lang=ja>振り仮名</span> should be inlined as
<p class=figure>振り仮名(ふりがな)
<p>and therefore marked up as
<pre>&lt;ruby&gt;
&lt;rb&gt;振&lt;/rb&gt;&lt;rb&gt;り&lt;/rb&gt;&lt;rb&gt;仮&lt;/rb&gt;&lt;rb&gt;名&lt;/rb&gt;
&lt;rp&gt;(&lt;/rp&gt;&lt;rt&gt;ふ&lt;/rt&gt;&lt;rt&gt;り&lt;/rt&gt;&lt;rt&gt;が&lt;/rt&gt;&lt;rt&gt;な&lt;/rt&gt;&lt;rp&gt;)&lt;/rp&gt;
&lt;ruby&gt;</pre>
<p>However, when displayed as ruby, the “り” should be hidden
<div class=figure>
<p><img alt="Hiragana annotations for 振り仮名 appear, each pronunciation above its kanji base character." src=images/furigana-separate.png>
<p class=caption>Hiragana ruby for 振り仮名. Notice there is no hiragana annotation above り, since it is already in hiragana.
</div>
</div>
<p>The content comparison for this auto-hiding behavior
takes place prior to white space collapsing (<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-white-space title=white-space>white-space</a>) and text transformation (<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-text-transform title=text-transform>text-transform</a>)
and ignores elements (considers only the <code>textContent</code> of the boxes).
<p class=note>
Future levels of CSS Ruby may add controls for auto-hiding,
but in this level it is always forced.
<h3 class="heading settled heading" data-level=2.5 id=white-space><span class=secno>2.5 </span><span class=content>
White Space Collapsing</span><a class=self-link href=#white-space></a></h3>
<p>White space within a ruby structure is <a href=#anon-gen-discard-space>discarded</a>
<ul>
<li>at the beginning and end of a <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>, <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>, or <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>,
<li>between a <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> and its following <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a>,
<li>between <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a>.
</ul>
<div class=example>
For example, the following markup will display without any spaces:
<pre>&lt;ruby&gt;
&lt;rb&gt;東&lt;/rb&gt;&lt;rb&gt;京&lt;/rb&gt;
&lt;rt&gt;とう&lt;/rt&gt;&lt;rt&gt;きょう&lt;/rt&gt;
&lt;rt&gt;Tō&lt;/rt&gt;&lt;rt&gt;kyō&lt;/rt&gt;
&lt;/ruby&gt;</pre>
</div>
<p>Between <a data-link-type=dfn href=#ruby-segments title="ruby segments">ruby segments</a>, between <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>, and between <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>, however,
white space is not discarded,
and is maintained for rendering
as <a data-link-type=dfn href=#inter-base-white-space title="inter-base white space">inter-base</a>,
<a data-link-type=dfn href=#inter-annotation-white-space title="inter-annotation white space">inter-annotation</a>,
or <a data-link-type=dfn href=#inter-segment-white-space title="inter-segment white space">inter-segment white space</a>.
(See <a href=#box-fixup>Anonymous Ruby Box Generation</a>, above.)
<div class=example>
<p>The rules preserving white space allow ruby to be used with space-separated scripts such as Latin.
For example,
<pre>&lt;ruby&gt;
&lt;rb&gt;W&lt;/rb&gt;&lt;rb&gt;W&lt;/rb&gt;&lt;rb&gt;W&lt;/rb&gt;
&lt;rt&gt;World&lt;/rt&gt; &lt;rt&gt;Wide&lt;/rt&gt; &lt;rt&gt;Web&lt;/rt&gt;
&lt;/ruby&gt;</pre>
<p>They also ensure that annotated white space is preserved. For example,
<pre>&lt;ruby&gt;
&lt;rb&gt;Aerith&lt;/rb&gt;&lt;rb&gt; &lt;/rb&gt;&lt;rb&gt;Gainsboro&lt;/rb&gt;
&lt;rt&gt;エアリス&lt;/rt&gt;&lt;rt&gt;・&lt;/rt&gt;&lt;rt&gt;ゲインズブール&lt;/rt&gt;
&lt;/ruby&gt;</pre>
</div>
<p>Where undiscarded white space is <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#collapsible-white-space title=collapsible>collapsible</a>, it will collapse
following the standard <a href=http://www.w3.org/TR/css3-text/#white-space-rules>white space processing rules</a>. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3text title=biblio-CSS3TEXT>[CSS3TEXT]</a>
For <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#collapsible-white-space title="collapsible white space">collapsible white space</a> between <a data-link-type=dfn href=#ruby-segments title="ruby segments">ruby segments</a> (<a data-link-type=dfn href=#inter-segment-white-space title="inter-segment white space">inter-segment white space</a>), however,
the contextual text for determining collapsing behavior is given by the <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> on either side,
not the text on either side of the white space in source document order.
<div class=note>
<p>Note that the white space processing rules
cause a white space sequence containing a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#segment-break title="segment break">segment break</a> (such as a line feed)
to <a href=http://www.w3.org/TR/css3-text/#line-break-transform>collapse to nothing</a> between Han and Kana characters.
This means that Chinese and Japanese ruby can safely use white space for indentation of ruby markup.
For example, the following markup will display without any spaces:
<pre>&lt;ruby&gt;
屋&lt;rt&gt;おく&lt;/rt&gt;内&lt;rt&gt;ない&lt;/rt&gt;
禁&lt;rt&gt;きん&lt;/rt&gt;煙&lt;rt&gt;えん&lt;/rt&gt;
&lt;/ruby&gt;</pre>
<p>However, white space that does not contain a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#segment-break title="segment break">segment break</a> does not collapse completely away,
so this markup will display with a space between the first and second ruby pairs:
<pre>&lt;ruby&gt;
屋&lt;rt&gt;おく&lt;/rt&gt; 内&lt;rt&gt;ない&lt;/rt&gt;
禁&lt;rt&gt;きん&lt;/rt&gt; 煙&lt;rt&gt;えん&lt;/rt&gt;
&lt;/ruby&gt;</pre>
</div>
<h2 class="heading settled heading" data-level=3 id=ruby-layout><span class=secno>3 </span><span class=content>
Ruby Layout</span><a class=self-link href=#ruby-layout></a></h2>
<p>When a ruby structure is laid out,
its <a data-link-type=dfn href=#base-level title="base level">base level</a> is laid out on the line,
aligned according to its <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-vertical-align title=vertical-align>vertical-align</a> property
exactly as if its <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> were a regular sequence of inline boxes.
Each <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> is sized and positioned
to contain exactly the full height of its <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
<p><a data-link-type=dfn href=#ruby-annotation-box title="Ruby annotations">Ruby annotations</a> associated with the <a data-link-type=dfn href=#base-level title="base level">base level</a>
are then positioned with respect to their <a data-link-type=dfn href=#ruby-base-box title="ruby base boxes">ruby base boxes</a>
according to the applicable <a class=property data-link-type=propdesc href=#propdef-ruby-position title=ruby-position>ruby-position</a> values.
<a data-link-type=dfn href=#ruby-annotation-box title="Ruby annotations">Ruby annotations</a> within a level (within a single <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>)
are aligned to each other as if they were inline boxes
participating in the same inline formatting context.
Each <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a> is sized and positioned
to contain exactly the full height of its <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>.
<p>A ruby container (or fragment thereof)
measures as wide as the content of its widest level.
Similarly, <a data-link-type=dfn href=#ruby-base-box title="ruby base boxes">ruby base boxes</a> and <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation boxes">ruby annotation boxes</a>
within a ruby “column” have the measure of the widest content in that “column”.
In the case of <a data-link-type=dfn href=#spanning-annotation title="spanning annotations">spanning annotations</a>
(whether actually spanning or pretending to span per <a class=property data-link-type=propdesc href=#propdef-ruby-merge title=ruby-merge>ruby-merge</a>),
the measures of the <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation box">ruby annotation box</a> and
the sum of its associated <a data-link-type=dfn href=#ruby-base-box title="ruby base boxes">ruby base boxes</a> must match.
<p>How the extra space is distributed
when ruby content is narrower than the measure of its box
is specified by the <a class=property data-link-type=propdesc href=#propdef-ruby-align title=ruby-align>ruby-align</a> property.
<h3 class="heading settled heading" data-level=3.1 id=inter-character-layout><span class=secno>3.1 </span><span class=content>
Inter-character Ruby Layout</span><a class=self-link href=#inter-character-layout></a></h3>
<p>Inter-character annotations have special layout.
When <a class=property data-link-type=propdesc href=#propdef-ruby-position title=ruby-position>ruby-position</a> indicates <a class=css data-link-type=maybe href=#valuedef-ruby-position-inter-character title=inter-character>inter-character</a> annotations,
the affected <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation boxes">ruby annotation boxes</a>
are spliced into and measured as part of the layout of the <a data-link-type=dfn href=#base-level title="base level">base level</a>.
The <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a> must be sized to include both the <a data-link-type=dfn href=#ruby-base-box title="ruby base boxes">ruby base boxes</a>
as well as the <a class=css data-link-type=maybe href=#valuedef-ruby-position-inter-character title=inter-character>inter-character</a> <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation boxes">ruby annotation boxes</a>.
The affected <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container">ruby annotation container</a> is similarly sized
so that its content box coincides with that of the <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>.
<p>For the purpose of laying out other levels of annotations,
an <a class=css data-link-type=maybe href=#valuedef-ruby-position-inter-character title=inter-character>inter-character</a> annotation effectively becomes part of its base.
<span class=issue id=issue-029133da><a class=self-link href=#issue-029133da></a>Or should it become a quasi-base between two bases?</span>
A spanning <a class=css data-link-type=maybe href=#valuedef-ruby-position-inter-character title=inter-character>inter-character</a> annotation is placed after
all the bases that it spans.
<h3 class="heading settled heading" data-level=3.2 id=box-style><span class=secno>3.2 </span><span class=content>
Styling Ruby Boxes</span><a class=self-link href=#box-style></a></h3>
<p>In most respects, ruby boxes can be styled similar to inline boxes.
However, the UA is not required to support
any of the box properties (borders, margins, padding),
any of the background properties or outline properties,
or any other property that illustrates the bounds of the box
on <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container boxes">ruby base container boxes</a>, <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation container boxes">ruby annotation container boxes</a>,
or <a href=#nested-pairing>ruby-internal ruby container boxes</a>.
The UA may implement these boxes simply as abstractions for inheritance
and control over the layout of their contents.
<h3 class="heading settled heading" data-level=3.3 id=line-breaks><span class=secno>3.3 </span><span class=content>
Breaking Across Lines</span><a class=self-link href=#line-breaks></a></h3>
<p>When there is not enough space for an entire <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> to fit on the line,
the ruby may be broken wherever all levels simultaneously allow a break.
Ruby most often breaks between base-annotation sets,
but if the line-breaking rules allow it, can also break within a <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a>
(and, in parallel, its associated <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation boxes">ruby annotation boxes</a>).
<p>Whenever ruby breaks across lines, <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> must stay
with their respective <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
The line <em>must not</em> break between a <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> and its <a data-link-type=dfn href=#ruby-annotation-box title=annotations>annotations</a>,
even in the case of <a class=css data-link-type=maybe href=#valuedef-ruby-position-inter-character title=inter-character>inter-character</a> <a data-link-type=dfn href=#ruby-annotation-box title=annotations>annotations</a>.
<div class=figure>
<img alt='Diagram showing the line breaking opportunity in a "Bopomofo" ruby' src=images/r-break-b.gif>
<p class=caption><a class=css data-link-type=maybe href=#valuedef-ruby-position-inter-character title=inter-character>inter-character</a> ruby line breaking opportunity
</div>
<h4 class="heading settled heading" data-level=3.3.1 id=break-between><span class=secno>3.3.1 </span><span class=content>
Breaking Between Bases</span><a class=self-link href=#break-between></a></h4>
<p>In typical cases, <a data-link-type=dfn href=#ruby-base-box title="ruby base boxes">ruby base boxes</a> and <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation boxes">ruby annotation boxes</a>
are styled to forbid internal line wrapping and do not contain forced breaks.
(See <a href=#default-stylesheet>Appendix A</a>.)
In such cases the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a> can only break between adjacent <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>,
and only if no <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> span those <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
<div class=figure>
<p><img alt="Diagram showing the line breaking opportunity in a complex ruby" src=images/r-break-a.gif>
<p class=caption>Ruby line breaking opportunity
</div>
<p>Whether ruby can break between two adjacent <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>
is controlled by normal line-breaking rules for the base text,
exactly as if the <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> were adjacent inline boxes.
(The annotations are ignored when determining soft wrap opportunities for the <a data-link-type=dfn href=#base-level title="base level">base level</a>.)
<div class=example>
<p>For example, if two adjacent ruby bases are “蝴” and “蝶”,
the line may break between them,
because lines are normally allowed to break between two Han characters.
However, if <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-word-break title=word-break>word-break</a> is <span class=css data-link-type=maybe title=keep-all>keep-all</span>, that line break is forbidden.
<pre>&lt;ruby&gt;蝴&lt;rt&gt;hú&lt;/rt&gt;蝶&lt;rt&gt;dié&lt;/rt&gt;</pre>
</div>
<p>Inter-base white space is significant for evaluating line break opportunities between <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
As with white space between inlines, it collapses when the line breaks there.
Similarly, annotation white space is also trimmed at a line break.
<div class=example>
<p>For example, given the following markup:
<pre>&lt;ruby&gt;&lt;rb&gt;one&lt;/rb&gt; &lt;rb&gt;two&lt;/rb&gt; &lt;rt&gt;1&lt;/rt&gt; &lt;rt&gt;2&lt;/rt&gt;&lt;/ruby&gt;</pre>
<p>Due to the space, the line may break between “one” and “two“.
If the line breaks there, that space—and the space between “1” and “2”—disappears,
in accordance with standard CSS white space processing rules. <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3text title=biblio-CSS3TEXT>[CSS3TEXT]</a>
</div>
<h4 class="heading settled heading" data-level=3.3.2 id=break-within><span class=secno>3.3.2 </span><span class=content>
Breaking Within Bases</span><a class=self-link href=#break-within></a></h4>
<p>For longer base texts, it is sometimes appropriate to allow breaking within a base-annotation pair.
For example, if an English sentence is annotated with its Japanese translation,
allowing the text to wrap allows for reasonable line breaking behavior in the paragraph.
<p class=issue id=issue-14d7c6b1><a class=self-link href=#issue-14d7c6b1></a>
Insert scanned example so people don’t think this is just the ramblings of an insane spec-writer.
<p>Line-breaking within a <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> is only allowed if the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-white-space title=white-space>white-space</a> property
of the <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> and all its parallel <a data-link-type=dfn href=#ruby-annotation-box title=annotations>annotations</a> allow it,
and there exists a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-text-3/#soft-wrap-opportunity title="soft wrap opportunity">soft wrap opportunity</a> <em>within</em> (i.e. not at the start or end)
the content of each base/annotation box.
Since there is no structural correspondence between fragments of content
within <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> and <a data-link-type=dfn href=#ruby-annotation-box title=annotations>annotations</a>,
the UA may break at any set of opportunities;
but it is recommended that the UA attempt to proportionally balance
the amount of content inside each fragment.
<p>There are no line breaking opportunities within <a class=css data-link-type=maybe href=#valuedef-ruby-position-inter-character title=inter-character>inter-character</a> <a data-link-type=dfn href=#ruby-annotation-box title=annotations>annotations</a>.
<p>Ruby alignment takes place within each fragment, after line-breaking.
<h3 class="heading settled heading" data-level=3.4 id=bidi><span class=secno>3.4 </span><span class=content>
Bidi Reordering</span><a class=self-link href=#bidi></a></h3>
<p>The Unicode bidirectional algorithm reorders logically-stored text for visual presentation
when characters from scripts of opposing directionalities are mixed
within a single paragraph.
<p>To preserve the correspondance of <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>
to their respective <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>,
a few restrictions must be imposed:
<ul>
<li>The contents of a <a data-link-type=dfn href=#ruby-base-box title="ruby base">ruby base</a> or <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> must remain contiguous.
<li><a data-link-type=dfn href=#ruby-annotation-box title="Ruby annotations">Ruby annotations</a> must be reordered together with their <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a>.
<li>All <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> spanned by a single <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation">ruby annotation</a> must remain contiguous.
</ul>
<p>To this end,
<ul>
<li>
Bidi isolation is forced on all <a data-link-type=dfn href=#internal-ruby-boxes title="internal ruby boxes">internal ruby boxes</a> and the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>:
the <span class=css data-link-type=maybe title=normal>normal</span> and <span class=css data-link-type=maybe title=embed>embed</span> values of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-unicode-bidi title=unicode-bidi>unicode-bidi</a> compute to <span class=css data-link-type=maybe title=isolate>isolate</span>,
and <span class=css data-link-type=maybe title=bidi-override>bidi-override</span> computes to <span class=css data-link-type=maybe title=isolate-override>isolate-override</span>.
<p class=note>
Note this means that implicit bidi reordering does not work across ruby bases,
so authors will need to ensure that the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>’s declared directionality
does indeed match its contents.
<li>
During layout, <a data-link-type=dfn href=#ruby-segments title="ruby segments">ruby segments</a> are ordered within the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>
by the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-direction title=direction>direction</a> property of their <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>.
<li>
Within a segment, <a data-link-type=dfn href=#ruby-base-box title="ruby bases">ruby bases</a> and <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a>
are ordered within their respective containers
by the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-direction title=direction>direction</a> property of the segment’s <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>.
<span class=note>
Note this means the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-direction title=direction>direction</a> property on <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a>
is ignored for the purpose of layout.
However, it can still inherit into the container’s children
and thereby affect the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-base-direction title="inline base direction">inline base direction</a>
of any <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotations">ruby annotations</a> it contains.
</span>
</ul>
<p>As with other inline-level content,
the bidi reordering of <a data-link-type=dfn href=#internal-ruby-boxes title="internal ruby boxes">internal ruby boxes</a> happens after line-breaking
so that content is divided across lines according to its logical order.
<p>See <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3-writing-modes title=biblio-CSS3-WRITING-MODES>[CSS3-WRITING-MODES]</a> for a more in-depth discussion of bidirectional text in CSS.
<h3 class="heading settled heading" data-level=3.5 id=line-height><span class=secno>3.5 </span><span class=content>
Line Spacing</span><a class=self-link href=#line-height></a></h3>
<p>The <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height title=line-height>line-height</a> property controls spacing between lines in CSS.
When inline content on line is shorter than the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height title=line-height>line-height</a>,
half-leading is added on either side of the content,
as specified in <a href=http://www.w3.org/TR/CSS21/visudet.html#line-height>CSS2.1§10.8</a>. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-CSS21>[CSS21]</a>
<p>In order to ensure consistent spacing of lines,
documents with ruby typically ensure that the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height title=line-height>line-height</a> is large enough
to accommodate ruby between lines of text.
Therefore, ordinarily, <a data-link-type=dfn href=#ruby-annotation-container-box title="ruby annotation containers">ruby annotation containers</a> and <a data-link-type=dfn href=#ruby-annotation-box title="ruby annotation boxes">ruby annotation boxes</a>
do not contribute to the measured height of a line’s inline contents;
any alignment (see <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-vertical-align title=vertical-align>vertical-align</a>) and line-height calculations
are performed using only the <a data-link-type=dfn href=#ruby-base-container-box title="ruby base container">ruby base container</a>,
exactly as if it were a normal inline.
<p>However, if the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height title=line-height>line-height</a> specified on the <a data-link-type=dfn href=#ruby-container title="ruby container">ruby container</a>