8000 csswg-drafts/css-ruby/Overview.html at 22e1e281ea51c9810ace56ea6de03e017385158d · xfq/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
2511 lines (1956 loc) · 99.6 KB

File metadata and controls

2511 lines (1956 loc) · 99.6 KB
<!DOCTYPE html>
<!--
Issues:
bidi
box layout/sizing
clean up inter-character vs. parallel layout requirements
Redo all examples with consistent font. (M+ 2p?)
-->
<html lang=en>
<head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Ruby Module Level 1</title>
<!--
<link href="http://purl.org/dc/terms/" rel="schema.dcterms">
<link href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright" rel="dcterms.rights">
-->
<meta content="CSS Ruby Module Level 1" name=dcterms.title>
<meta content=text name=dcterms.type>
<meta content=2013-09-13 name=dcterms.date>
<meta content="Elika J. Etemad" name=dcterms.creator>
<meta content="Koji Ishii" name=dcterms.creator>
<meta content="Richard Ishida" name=dcterms.creator>
<meta content=W3C name=dcterms.publisher>
<meta content="http://dev.w3.org/csswg/css3-ruby/" name=dcterms.identifier>
<link href="#contents" rel=contents>
<link href="#index" rel=index>
<link href="../default.css" rel=stylesheet type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<body class=h-entry>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1 class=p-name>CSS Ruby Module Level 1</h1>
<h2 class="no-num no-toc" id=longstatus-date->Editor's Draft <time
class=dt-updated datetime=20130913>13 September 2013</time>
<!-- for HTML4 doctype: <span class="value-title" title="20130913">13 September 2013</span></span> --></h2>
<dl>
<dt>This version:
<dd><a class=u-url
href="http://dev.w3.org/csswg/css3-ruby/">http://dev.w3.org/csswg/css3-ruby/</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-ruby/">http://www.w3.org/TR/css3-ruby/</a>
<dt>Editor's draft:
<dd><a
href="http://dev.w3.org/csswg/css3-ruby/">http://dev.w3.org/csswg/css3-ruby/</a>
(<a
href="https://dvcs.w3.org/hg/csswg/log/tip/css3-ruby/Overview.src.html">change
log</a>)
<dt>Previous version:
<dd><a href="http://www.w3.org/TR/2011/WD-css3-ruby-20110630/">
http://www.w3.org/TR/2011/WD-css3-ruby-20110630/</a>
<dt>Issue Tracking:
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/FIXME"
rel=issues>http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
<dt>Feedback:
<dd><a
href="mailto:www-style@w3.org?subject=%5BSHORTNAME%5D%20feedback">www-style@w3.org</a>
with subject line “<kbd>[css3-ruby] <var>… message topic
…</var></kbd>” (<a
href="http://lists.w3.org/Archives/Public/www-style/"
rel=discussion>archives</a>)
<dt>Editors:
<dd class="p-author h-card vcard"> <a class="p-name fn u-url url"
href="http://fantasai.inkedblade.net/contact" rel=author>Elika J.
Etemad</a>, <a class="p-org org h-org"
href="http://www.mozilla.org/">Mozilla</a>
<dd class="p-author h-card vcard"> <a class="p-name fn u-url url"
href="mailto:koji.a.ishii@mail.rakuten.com" rel=author>Koji Ishii</a>,
<span class="p-org org">Rakuten, Inc.</span>
<dd class="p-author h-card vcard"> <a class="p-name fn u-url url"
href="mailto:ishida@w3.org" rel=author>Ric 135D hard Ishida</a>, <span
class="p-org org">W3C</span>
<dt>Former editors:
<dd>Michel Suignard, Microsoft
<dd>Marcin Sawicki, Microsoft
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2013 <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> 6D31 ;, <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>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p> <span class=p-summary> “Ruby” are short runs of text alongside the
base text, 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. </span> <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.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-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=%5Bcss3-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
“css3-ruby” in the subject, preferably like this:
“[<!---->css3-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>.</p>
<!--end-status-->
<p>The following features are at risk: …
<h2 class="no-num no-toc" id=contents> Table of Contents</h2>
<!--begin-toc-->
<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 Formatting
Model</a>
<ul class=toc>
<li><a href="#ruby-display"><span class=secno>2.1. </span> Ruby-specific
‘<code class=property>display</code>’ property values</a>
<li><a href="#box-fixup"><span class=secno>2.2. </span> Anonymous Ruby
Box Generation</a>
<li><a href="#pairing"><span class=secno>2.3. </span> Ruby Pairing and
Annotation Levels</a>
<ul class=toc>
<li><a href="#nested-pairing"><span class=secno>2.3.1. </span> Nested
Ruby</a>
</ul>
<li><a href="#autohide"><span class=secno>2.4. </span> Autohiding
Annotations</a>
<li><a href="#white-space"><span class=secno>2.5. </span> White
Space</a>
<li><a href="#ruby-layout"><span class=secno>2.6. </span> Ruby
layout</a>
<ul class=toc>
<li><a href="#inter-character-layout"><span class=secno>2.6.1. </span>
Inter-character ruby layout</a>
</ul>
<li><a href="#box-style"><span class=secno>2.7. </span> Styling Ruby
Boxes</a>
<li><a href="#line-breaks"><span class=secno>2.8. </span> Ruby box and
line breaking</a>
<ul class=toc>
<li><a href="#break-between"><span class=secno>2.8.1. </span> Breaking
between bases</a>
<li><a href="#break-within"><span class=secno>2.8.2. </span> Breaking
within bases</a>
</ul>
<li><a href="#ruby-bidi"><span class=secno>2.9. </span> Bidi
Reordering</a>
<li><a href="#line-height"><span class=secno>2.10. </span> Ruby box and
line stacking</a>
</ul>
<li><a href="#ruby-props"><span class=secno>3. </span> Ruby Properties</a>
<ul class=toc>
<li><a href="#rubypos"><span class=secno>3.1. </span> Ruby positioning:
the ‘<code class=property>ruby-position</code>’ property</a>
<li><a href="#collapsed-ruby"><span class=secno>3.2. </span> Collapsed
Ruby Annotations: the ‘<code class=property>ruby-merge</code>’
property</a>
<li><a href="#ruby-align-property"><span class=secno>3.3. </span> Ruby
Text Distribution: the ‘<code class=property>ruby-align</code>’
property</a>
</ul>
<li><a href="#edge-effects"><span class=secno>4. </span> Edge Effects</a>
<ul class=toc>
<li><a href="#ruby-overhang"><span class=secno>4.1. </span> Overhanging
Ruby</a>
<li><a href="#line-edge"><span class=secno>4.2. </span> Line-edge
Alignment</a>
</ul>
<li class=no-num><a href="#default-stylesheet"> Appendix A: Default Style
Sheet</a>
<ul class=toc>
<li class=no-num><a href="#default-ua-ruby"> Supporting Ruby Layout</a>
<li class=no-num><a href="#default-inline"> Inlining Ruby
Annotations</a>
<li class=no-num><a href="#default-parens"> Generating Parentheses</a>
</ul>
<li><a href="#glossary"><span class=secno>5. </span> Glossary</a>
<li><a href="#conformance"><span class=secno>6. </span> Conformance</a>
<ul class=toc>
<li><a href="#conventions"><span class=secno>6.1. </span> Document
conventions</a>
<li><a href="#conformance-classes"><span class=secno>6.2. </span>
Conformance classes</a>
<li><a href="#partial"><span class=secno>6.3. </span> Partial
implementations</a>
<li><a href="#experimental"><span class=secno>6.4. </span> Experimental
implementations</a>
<li><a href="#testing"><span class=secno>6.5. </span> Non-experimental
implementations</a>
</ul>
<li class=no-num><a href="#acknowledgments"> Acknowledgments</a>
<li class=no-num><a href="#changes"> Changes</a>
<li class=no-num><a href="#references"> References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references"> Normative
references</a>
<li class=no-num><a href="#other-references"> Other references</a>
</ul>
<li class=no-num><a href="#index"> Index</a>
<li class=no-num><a href="#property-index"> Property index</a>
</ul>
<!--end-toc-->
<h2 id=intro><span class=secno>1. </span> Introduction</h2>
<p><em>This section is not normative.</em>
<h3 id=placement><span class=secno>1.1. </span> Module interactions</h3>
<p>This module extends the inline box model of CSS Level 2 <a href="#CSS21"
rel=biblioentry>[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 id=values><span class=secno>1.2. </span> Values</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 href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a
href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Other CSS
modules may expand the definitions of these value types: for example <a
href="#CSS3VAL" rel=biblioentry>[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>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 id=diagram-conventions><span class=secno>1.3. </span> Diagram
conventions</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 id=ruby-def><span class=secno>1.4. </span> What is ruby?</h3>
<p><dfn id=ruby>Ruby</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 <i
lang=ja>taigo</i> 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 <i>collapsed annotation</i>, 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 href="#ruby"><i>Ruby</i></a> formatting as used in Japanese is
described in JIS X-4051 <a href="#JIS4051"
rel=biblioentry>[JIS4051]<!--{{JIS4051}}--></a> (in Japanese) and in
Requirements for Japanese Text Layout <a href="#JLREQ"
rel=biblioentry>[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 id=ruby-model><span class=secno>2. </span> Ruby Formatting Model</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 href="#RUBY"
rel=biblioentry>[RUBY]<!--{{RUBY}}--></a>. In this model, a ruby structure
consists of one or more <dfn id=ruby-base>ruby base</dfn> elements
representing the base (annotated) text, associated with one or more levels
of <dfn id=ruby-annotation>ruby annotation</dfn> elements representing the
annotations. The structure of ruby is similar to that of a table: there
are “rows” (the base text level, each annotation level) and
“columns” (each <a href="#ruby-base-box"><i>ruby base</i></a> and its
corresponding <a href="#ruby-annotation-box"><i>ruby annotations</i></a>).
<p>Consecutive bases and annotations are grouped together into <dfn
id=ruby-segments>ruby segments</dfn>. Within a <i>ruby segment</i>, a <a
href="#ruby-annotation-box"><i>ruby annotation</i></a> may span multiple
<a href="#ruby-base-box"><i>ruby bases</i></a>.
<p class=note>In HTML, a single <code>&lt;ruby&gt;</code> element may
contain multiple <a href="#ruby-segments"><i>ruby segments</i></a>. (In
the XHTML Ruby model, a single <code>&lt;ruby&gt;</code> element can only
contain one <i>ruby segment</i>.)
<h3 id=ruby-display><span class=secno>2.1. </span> Ruby-specific ‘<code
class=property>display</code>’ property values</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 ‘<code
class=property>display</code>’ property.
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td>display
<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 ‘<code class=property>display</code>’ values
assign ruby layout roles to an arbitrary element:
<dl>
<dt>‘<a href="#ruby"><code class=css>ruby</code></a>’
<dd>Specifies that an element generates a <dfn id=ruby-container-box
title="ruby container | ruby container box">ruby container box</dfn>.
(Corresponds to HTML/XHTML <code>&lt;ruby&gt;</code> elements.)
<dt>‘<code class=css>ruby-base</code>’
<dd>Specifies that an element generates a <dfn id=ruby-base-box
title="ruby base box | ruby base">ruby base box</dfn>. (Corresponds to
HTML/XHTML <code>&lt;rb&gt;</code> elements.)
<dt>‘<code class=css>ruby-text</code>’
<dd>Specifies that an element generates a <dfn id=ruby-annotation-box
title="ruby annotation box | ruby annotation">ruby annotation box</dfn>.
(Corresponds to HTML/XHTML <code>&lt;rt&gt;</code> elements.)
<dt>‘<code class=css>ruby-base-container</code>’
<dd>Specifies that an element generates a <dfn id=ruby-base-container-box
title="ruby base container box | ruby base container">ruby base container
box</dfn>. (Corresponds to XHTML <code>&lt;rbc&gt;</code> elements;
always implied in HTML.)
<dt>‘<code class=css>ruby-text-container</code>’
<dd>Specifies that an element generates a <dfn
id=ruby-annotation-container-box
title="ruby annotation container box | ruby annotation container">ruby
annotation container box</dfn>. (Corresponds to HTML/XHTML
<code>&lt;ruby&gt;</code> elements.)
</dl>
<h3 id=box-fixup><span class=secno>2.2. </span> Anonymous Ruby Box
Generation</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 href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>
<ol>
<li>Any in-flow block-level boxes directly contained by a <a
href="#ruby-container-box"><i>ruby container</i></a>, <a
href="#ruby-base-container-box"><i>ruby base container</i></a>, <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, <a href="#ruby-base-box"><i>ruby base box</i></a>, or
<a href="#ruby-annotation-box"><i>ruby annotation box</i></a> are forced
to be inline-level boxes, and their ‘<code
class=property>display</code>’ value computed accordingly. For example,
the ‘<code class=property>display</code>’ property of an in-flow
element with ‘<code class=css>display: block</code>’ parented by an
element with ‘<code class=css>display: ruby-text</code>’ computes to
‘<code class=css>inline-block</code>’. This computation occurs after
any intermediary anonymous-box fixup (such as that required by internal
table elements).
<li>Any consecutive sequence of <a href="#ruby-base-box"><i>ruby
bases</i></a> not parented by a <a
href="#ruby-base-container-box"><i>ruby base container</i></a> is wrapped
in an anonymous <a href="#ruby-base-container-box"><i>ruby base
container</i></a>. Similarly, any consecutive sequence of <a
href="#ruby-annotation-box"><i>ruby annotations</i></a> not parented by a
<a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a> is wrapped in an anonymous <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>.
<li>Within each <a href="#ruby-base-container-box"><i>ruby base
container</i></a>, each sequence of inline-level boxes is wrapped in an
anonymous <a href="#ruby-base-box"><i>ruby base box</i></a>. Similarly,
within each <a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, each sequence of inline-level boxes is wrapped in an
anonymous <a href="#ruby-annotation-box"><i>ruby annotation box</i></a>.
<li>A sequence of <a href="#ruby-base-container-box"><i>ruby base
containers</i></a> and/or <a
href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> not parented by a <a
href="#ruby-container-box"><i>ruby container</i></a> is wrapped in an
anonymous <a href="#ruby-container-box"><i>ruby container</i></a>.
</ol>
<p>At this point, all ruby layout structures are properly parented, and 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 in its internal structures, as long as pairing and layout
behaves as if they existed.
<h3 id=pairing><span class=secno>2.3. </span> Ruby Pairing and Annotation
Levels</h3>
<p>Within a ruby structure, each <a href="#ruby-base-box"><i>ruby
base</i></a> is associated with <a href="#ruby-annotation-box"><i>ruby
annotations</i></a> and vice versa. A <a href="#ruby-base-box"><i>ruby
base</i></a> can be associated with at most one <a
href="#ruby-annotation-box"><i>ruby annotation</i></a> per annotation
level. If there are multiple annotation levels, it can therefore be
associated with multiple <a href="#ruby-annotation-box"><i>ruby
annotations</i></a>. A <a href="#ruby-annotation-box"><i>ruby
annotation</i></a> is associated with one or more <a
href="#ruby-base-box"><i>ruby bases</i></a>; annotations can span multiple
bases.
<p><dfn id=annotation-pairing>Annotation pairing</dfn> is the process of
associating <a href="#ruby-annotation-box"><i>ruby annotations</i></a>
with <a href="#ruby-base-box"><i>ruby bases</i></a>.
<ol>
<li>
<p>First, the ruby structure is divided into <a
href="#ruby-segments"><i>ruby segments</i></a>, each consisting of a
single <a href="#ruby-base-container-box"><i>ruby base container</i></a>
followed by one or more <a href="#ruby-annotation-container-box"><i>ruby
annotation containers</i></a>. If the first child of a <a
href="#ruby-container-box"><i>ruby container</i></a> is a <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, an anonymous, empty <a
href="#ruby-base-container-box"><i>ruby base container</i></a> is
assumed to exist before it. Similarly, if the <a
href="#ruby-container-box"><i>ruby container</i></a> contains
consecutive <a href="#ruby-base-container-box"><i>ruby base
containers</i></a>, anonymous, empty <a
href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> are assumed to exist between them. The <a
href="#ruby-base-container-box"><i>ruby base container</i></a> in each
segment is thus associated with each of the <a
href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> in that segment.
<p>Each <a href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> in a <i>ruby segment</i> represents one <dfn id=level
title="annotation level | level">level</dfn> of annotation: the first
one represents the first level of annotation, the second one represents
the second level of annotation, and so on.
<li>Within each <i>ruby segment</i>, each <a href="#ruby-base-box"><i>ruby
base box</i></a> in the <a href="#ruby-base-container-box"><i>ruby base
container</i></a> is paired with one <a
href="#ruby-annotation-box"><i>ruby annotation box</i></a> from each <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a> in its <i>ruby segment</i>. If there are not enough <a
href="#ruby-annotation-box"><i>ruby annotations</i></a> in a <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, the last one is associated with any excess <a
href="#ruby-base-box"><i>ruby bases</i></a>. (If there are not any in the
<a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, an anonymous empty one is assumed to exist.) If there
are not enough <a href="#ruby-base-box"><i>ruby bases</i></a>, any
remaining <a href="#ruby-annotation-box"><i>ruby annotations</i></a> are
assumed to be associated with empty, anonymous bases inserted at the end
of the <a href="#ruby-base-container-box"><i>ruby base container</i></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 spanning annotations to multiple bases appropriately.
</ol>
<p>A this point, ruby “columns” are defined, each represented by a
single <a href="#ruby-base-box"><i>ruby base</i></a> and associated with
one <a href="#ruby-annotation-box"><i>ruby annotation</i></a> (possibly an
empty, anonymous one) from each <a href="#level"><i>annotation
level</i></a>.
<h4 id=nested-pairing><span class=secno>2.3.1. </span> Nested Ruby</h4>
<p>When <a href="#ruby-container-box"><i>ruby containers</i></a> are
nested, pairing begins with the deepest <a
href="#ruby-container-box"><i>ruby container</i></a>, then expands out,
treating each <a href="#ruby-container-box"><i>ruby container</i></a>
nested within another <a href="#ruby-container-box"><i>ruby
container</i></a> essentially as a single <a href="#ruby-base-box"><i>ruby
base</i></a> in the outer <a href="#ruby-container-box"><i>ruby
container</i></a>, and associating each <a
href="#ruby-annotation-box"><i>ruby annotation</i></a> paired with the
nested <a href="#ruby-container-box"><i>ruby container</i></a> as being
associated with (spanning) all of its <a href="#ruby-base-box"><i>ruby
bases</i></a>.
<p>Using nested <a href="#ruby-container-box"><i>ruby containers</i></a>
thus allows the representation of complex spanning relationships.
<p class=issue>This has to be Level 1 because HTML5 allows it, so we have
to handle it. Yay HTML5.
<h3 id=autohide><span class=secno>2.4. </span> Autohiding Annotations</h3>
<p>If a <a href="#ruby-annotation-box"><i>ruby annotation</i></a> has the
exact same text content as its base, it is <dfn id=hidden
title="hidden ruby annotation | hidden annotation">hidden</dfn>. Hiding a
<a href="#ruby-annotation-box"><i>ruby annotation</i></a> does not affect
annotation pairing or the block-axis positioning of boxes in other <a
href="#level"><i>levels</i></a>. However the <a href="#hidden"><i>hidden
annotation</i></a> is not visible, and it has no impact on layout other
than to separate adjacent sequences of <a
href="#ruby-annotation-box"><i>ruby annotation boxes</i></a> within its
level, as if they belonged to separate segments and the <a
href="#hidden"><i>hidden annotation</i></a>’s base were not a <a
href="#ruby-base-box"><i>ruby base</i></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 hirangana. For example, the word
<i>振り仮名</i> should be inlined as
<p class=figure>振り仮名(ふりがな)
<p>and therefore marked up as
<pre>
<!-- -->&lt;ruby>
<!-- --> &lt;rb>振&lt;/rb>&lt;rb>り&lt;/rb>&lt;rb>仮&lt;/rb>&lt;rb>名&lt;/rb>
<!-- --> &lt;rp>(&lt;/rp>&lt;rt>ふ&lt;/rt>&lt;rt>り&lt;/rt>&lt;rt>が&lt;/rt>&lt;rt>な&lt;/rt>&lt;rp>)&lt;/rp>
<!-- -->&lt;ruby></pre>
<p>However, when displayed as ruby, the “り” should be hidden
<div class=figure>
<p><img
alt="Hiragana annotations for 振り仮名 appear, each above its base character."
src="images/furigana-separate.png">
<p class=caption>Hiragana ruby for 振り仮名
</div>
</div>
<p class=note> Future levels of CSS Ruby may add controls for this, but in
this level it is always forced.
<p>The content comparison for this auto-hiding behavior takes place prior
to white space collapsing and ignores elements (considers only the
<code>textContent</code> of the boxes).
<p class=issue>Is before or after white space collapsing easier? We should
do whatever is easier, as it really doesn't matter much which way to go.
<h3 id=white-space><span class=secno>2.5. </span> White Space</h3>
<p><i>Collapsible</i> white space within a ruby structure is discarded
<ul>
<li>at the beginning and end of a <a href="#ruby-container-box"><i>ruby
container</i></a>, <a href="#ruby-annotation-container-box"><i>ruby
annotation container</i></a>, or <a
href="#ruby-base-container-box"><i>ruby base container</i></a>,
<li>at the beginning/end of a <a href="#ruby-annotation-box"><i>ruby
annotation box</i></a> or <a href="#ruby-base-box"><i>ruby base
box</i></a> if white space is not its only contents,
<li>between a <a href="#ruby-base-container-box"><i>ruby base
container</i></a> and its following <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>,
<li>between <a href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a>.
</ul>
<p>Between <a href="#ruby-segments"><i>ruby segments</i></a>, between <a
href="#ruby-base-box"><i>ruby bases</i></a>, and between <a
href="#ruby-annotation-box"><i>ruby annotations</i></a>, however, white
space is not discarded.
<p>Where undiscarded white space is <i>collapsible</i>, it will collapse
following the standard <a
href="http://www.w3.org/TR/css3-text/#white-space-rules">white space
processing rules</a>. <a href="#CSS3TEXT"
rel=biblioentry>[CSS3TEXT]<!--{{!CSS3TEXT}}--></a> For <i>collapsible</i>
white space between <a href="#ruby-segments"><i>ruby segments</i></a>,
however, the contextual text for determining collapsing behavior is given
by the <a href="#ruby-base-box"><i>ruby bases</i></a> on either side, not
the text on either side of the white space in the source document.
<div class=note>
<p>Note that the white space processing rules cause a white space sequence
containing a <i>segment break</i> (such as a line feed) to <a
href="http://www.w3.org/TR/css3-text/#line-break-transform">collapse to
nothing</a> between CJK characters. This means that CJK ruby can safely
use white space for indentation of the ruby markup. For example, the
following markup will display without any spaces:
<pre>
<!-- -->&lt;ruby>
<!-- --> &lt;rb>東&lt;/rb>&lt;rb>京&lt;/rb>
<!-- --> &lt;rt>とう&lt;/rt>&lt;rt>きょう&lt;/rt>
<!-- -->&lt;/ruby></pre>
<p>However, white space that does not contain a <i>segment break</i> does
not collapse completely away, so this markup will display with a space
between the first and second ruby pairs:
<pre>
<!-- -->&lt;ruby>
<!-- --> &lt;rb>東&lt;/rb> &lt;rb>京&lt;/rb>
<!-- --> &lt;rt>とう&lt;/rt> &lt;rt>きょう&lt;/rt>
<!-- -->&lt;/ruby></pre>
</div>
<p>Any preserved white space is then wrapped in an anonymous box belonging
to the <a href="#ruby-base-container-box"><i>ruby base container</i></a>
(if between <a href="#ruby-base-box"><i>ruby bases</i></a>), <a
href="#ruby-annotation-container-box"><i>ruby annotation container</i></a>
(if between <a href="#ruby-annotation-box"><i>ruby annotations</i></a>),
or <a href="#ruby-container-box"><i>ruby container</i></a> (if between <a
href="#ruby-segments"><i>ruby segments</i></a>). In the latter case, the
text is considered part of the <i>base level</i>. Such anonynmous boxes do
not take part in pairing. They merely ensure separation between adjacent
bases/annotations.
<p class=issue>Specify how these anonymous white space boxes impact layout.
<div class=example>
<p>These rules allow ruby to be used with space-separated scripts such as
Latin. For example,
<pre>
<!-- -->&lt;ruby>
<!-- --> &lt;rb>W&lt;/rb>&lt;rb>W&lt;/rb>&lt;rb>W&lt;/rb>
<!-- --> &lt;rt>World&lt;/rt> &lt;rt>Wide&lt;/rt> &lt;rt>Web&lt;/rt>
<!-- -->&lt;/ruby></pre>
<p>They also ensure that annotated white space is preserved. For example,
<pre>
<!-- -->&lt;ruby>
<!-- --> &lt;rb>Aerith&lt;/rb>&lt;rb> &lt;/rb>&lt;rb>Gainsboro&lt;/rb>
<!-- --> &lt;rt>エアリス&lt;/rt>&lt;rt>・&lt;/rt>&lt;rt>ゲインズブール&lt;/rt>
<!-- -->&lt;/ruby></pre>
</div>
<h3 id=ruby-layout><span class=secno>2.6. </span> Ruby layout</h3>
<p>When a ruby structure is laid out, its base level is laid out on the
line, aligned according to its ‘<code
class=property>vertical-align</code>’ property exactly as if its
<i>bases</i> were a regular sequence of <i>inline</i> boxes. Each <a
href="#ruby-base-container-box"><i>ruby base container</i></a> is sized
and positioned to contain exactly the full height of its <a
href="#ruby-base-box"><i>ruby bases</i></a>.
<p><a href="#ruby-annotation-box"><i>Ruby annotations</i></a> associated
with the base level are then positioned with respect to their <a
href="#ruby-base-box"><i>ruby base boxes</i></a> according to the
applicable ‘<a href="#ruby-position"><code
class=property>ruby-position</code></a>’ values. <a
href="#ruby-annotation-box"><i>Ruby annotations</i></a> within a level
(within a single <a href="#ruby-container-box"><i>ruby container</i></a>)
are aligned to each other as if they were inline boxes participating in
the same inline formatting context. Each <a
href="#ruby-annotation-container-box"><i>ruby annotation container</i></a>
is sized and positioned to contain exactly the full height of its <a
href="#ruby-annotation-box"><i>ruby annotations</i></a>.
<p>A ruby container (or fragment thereof) measures as wide as the content
of its widest level. Similarly, <a href="#ruby-base-box"><i>ruby base
boxes</i></a> and <a href="#ruby-annotation-box"><i>ruby annotation
boxes</i></a> within a ruby “column” have the measure of the wide 82B1 st
content in that “column”. In the case of spanning <i>annotations</i>
(whether actually spanning or pretending to span per ‘<code
class=property>ruby-collapse</code>’), the measures of the <a
href="#ruby-annotation-box"><i>ruby annotation box</i></a> and the sum of
its associated <a href="#ruby-base-box"><i>ruby base boxes</i></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 href="#ruby-align"><code
class=property>ruby-align</code></a>’ property.
<h4 id=inter-character-layout><span class=secno>2.6.1. </span>
Inter-character ruby layout</h4>
<p>Inter-character annotations have special layout. When ‘<a
href="#ruby-position"><code class=property>ruby-position</code></a>’
indicates ‘<code class=css>inter-character</code>’ annotations, the
affected <i>annotation boxes</i> are spliced into and measured as part of
the layout of the base level. The <a
href="#ruby-base-container-box"><i>ruby base container</i></a> must be
sized to include both the <i>base boxes</i> as well as the ‘<code
class=css>inter-character</code>’ <i>annotation boxes</i>. The affected
<a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a> is similarly sized so that its content box coincides
with that of the <a href="#ruby-base-container-box"><i>ruby base
container</i></a>.
<p>For the purpose of laying out other levels of annotations, an ‘<code
class=css>inter-character</code>’ annotation effectively becomes part of
its base. <span class=issue>Or should it become a quasi-base between two
bases?</span> A spanning ‘<code class=css>inter-character</code>’
annotation is placed after all the bases that it spans.
<h3 id=box-style><span class=secno>2.7. </span> Styling Ruby Boxes</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 href="#ruby-base-container-box"><i>ruby base container
boxes</i></a>, <a href="#ruby-annotation-container-box"><i>ruby annotation
container boxes</i></a>, or <a href="#nested-pairing">ruby-internal
<i>ruby container boxes</i></a>. The UA may implement these boxes simply
as abstractions for inheritance and control over the layout of their
contents.
<p class=issue> Alternatively... use margins to control offsets? Or could
line-height be adequate? Its centering behavior can be awkward.
<h3 id=line-breaks><span class=secno>2.8. </span> Ruby box and line
breaking</h3>
<p>When there is not enough space for an entire <a
href="#ruby-container-box"><i>ruby container</i></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
href="#ruby-base-box"><i>ruby base</i></a> (and, in parallel, its
associated <i>annotation boxes</i>).
<p>Whenever ruby breaks across lines, <a
href="#ruby-annotation-box"><i>ruby annotations</i></a> must stay with
their respective <i>bases</i>. The line <em>must not</em> break between a
<a href="#ruby-base-box"><i>ruby base</i></a> and its <i>annotations</i>,
even in the case of ‘<code class=css>inter-character</code>’
<i>annotations</i>.
<div class=figure> <img
alt="Diagram showing the line breaking opportunity in a &#34;Bopomofo&#34; ruby"
src="images/r-break-b.gif">
<p class=caption>‘<code class=css>inter-character</code>’ ruby line
breaking opportunity
</div>
<h4 id=break-between><span class=secno>2.8.1. </span> Breaking between
bases</h4>
<p>In typical cases, <a href="#ruby-base-box"><i>ruby base boxes</i></a>
and <a href="#ruby-annotation-box"><i>ruby annotation boxes</i></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
href="#ruby-container-box"><i>ruby container</i></a> can only break
between adjacent <a href="#ruby-base-box"><i>ruby bases</i></a>, and only
if no <a href="#ruby-annotation-box"><i>ruby annotations</i></a> span
those <a href="#ruby-base-box"><i>ruby bases</i></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
href="#ruby-base-box"><i>ruby bases</i></a> is controlled by normal
line-breaking rules for the base text, exactly as if the <a
href="#ruby-base-box"><i>ruby bases</i></a> were adjacent <i>inline</i>
boxes. (The annotations are ignored when determining soft wrap
opportunities for the base level.)
<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 ‘<code
class=property>word-break</code>’ is ‘<code
class=css>keep-all</code>’, that line break is forbidden.
<pre>&lt;ruby>蝴&lt;rt>hú&lt;/rt>蝶&lt;rt>dié&lt;/rt></pre>
</div>
<p>Inter-base white space is significant for evaluating line break
opportunities between <a href="#ruby-base-box"><i>ruby bases</i></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 50E5 the following markup:
<pre>&lt;ruby>&lt;rb>one&lt;/rb> &lt;rb>two&lt;/rb> &lt;rt>1&lt;/rt> &lt;rt>2&lt;/rt>&lt;/ruby></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 href="#CSS3TEXT"
rel=biblioentry>[CSS3TEXT]<!--{{CSS3TEXT}}--></a>
</div>
<h4 id=break-within><span class=secno>2.8.2. </span> Breaking within bases</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> Insert scanned example so people don't think this is just
the ramblings of an insane spec-writer.
<p>Line-breaking within a <a href="#ruby-base-box"><i>ruby base</i></a> is
only allowed if the ‘<code class=property>white-space</code>’ property
of the <a href="#ruby-base-box"><i>ruby base</i></a> and all its parallel
<i>annotations</i> allow it, and there exists a <i>soft wrap
opportunity</i> <em>within</em> (i.e. not at the start or end) the content
of each base/annotation box. Since there is no structural correspondance
between fragments of content within <a href="#ruby-base-box"><i>ruby
bases</i></a> and <i>annotations</i>, 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.