Mon, 08 Jul 2013 17:37:11 -0700
[css-ruby] typo
1 <!--
3 Issues:
4 bidi
5 box layout/sizing
7 Redo all examples with consistent font. (M+ 2p?)
9 -->
11 <!DOCTYPE html>
12 <html lang="en">
13 <head>
14 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
15 <title>CSS Ruby Module Level 1</title>
16 <link rel=contents href="#contents">
17 <link rel=index href="#index">
18 <link rel="stylesheet" type="text/css" href="../default.css">
19 <link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
20 <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
21 </head>
23 <body class="h-entry">
25 <div class="head">
26 <!--logo-->
28 <h1 class="p-name">CSS Ruby Module Level 1</h1>
30 <h2 class="no-num no-toc">[LONGSTATUS] <time class="dt-updated" datetime="[CDATE]">[DATE]</time> <!-- for HTML4 doctype: <span class="value-title" title="[CDATE]">[DATE]</span></span> --> </h2>
31 <dl>
32 <dt>This version:
33 <dd><a class="u-url" href="[VERSION]">[VERSION]</a>
35 <dt>Latest version:
36 <dd><a href="http://www.w3.org/TR/[SHORTNAME]/">http://www.w3.org/TR/css3-ruby/</a>
38 <dt>Editor's draft:
39 <dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
40 (<a href="https://dvcs.w3.org/hg/csswg/log/tip/[SHORTNAME]/Overview.src.html">change log</a>)
42 <dt>Previous version:
43 <dd><a href="http://www.w3.org/TR/2011/WD-css3-ruby-20110630/">
44 http://www.w3.org/TR/2011/WD-css3-ruby-20110630/</a>
46 <dt>Issue Tracking:</dt>
47 <dd><a rel="issues" href="http://www.w3.org/Style/CSS/Tracker/products/FIXME">http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
49 <dt>Feedback:</dt>
50 <dd><a href="mailto:www-style@w3.org?subject=%5BSHORTNAME%5D%20feedback"
51 >www-style@w3.org</a>
52 with subject line “<kbd>[[SHORTNAME]]
53 <var>… message topic …</var></kbd>”
54 (<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/"
55 >archives</a>)
57 <dt>Editors:
58 <dd class="p-author h-card vcard">
59 <a class="p-name fn u-url url" rel="author"
60 href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a>,
61 <a class="p-org org h-org" href="http://www.mozilla.org/">Mozilla</a>
62 <dd class="p-author h-card vcard">
63 <a class="p-name fn u-url url" rel="author"
64 href="mailto:koji.a.ishii@mail.rakuten.com">Koji Ishii</a>,
65 <span class="p-org org">Rakuten, Inc.</span>
66 <dd class="p-author h-card vcard">
67 <a class="p-name fn u-url url" rel="author"
68 href="mailto:ishida@w3.org">Richard Ishida</a>,
69 <span class="p-org org">W3C</span>
71 <dt>Former editors:
72 <dd>Michel Suignard, Microsoft
73 <dd>Marcin Sawicki, Microsoft
74 </dl>
76 <!--copyright-->
78 <hr title="Separator for header">
79 </div>
81 <h2 class="no-num no-toc" id="abstract">Abstract</h2>
83 <p>
84 <span class="p-summary">
85 “Ruby” are short runs of text alongside the base text,
86 typically used in East Asian documents to indicate pronunciation
87 or to provide a short annotation.
88 This module describes the rendering model and formatting controls
89 related to displaying ruby annotations in CSS.
90 </span>
92 <a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing
93 the rendering of structured documents (such as HTML and XML) on screen, on
94 paper, in speech, etc.
96 <h2 class="no-num no-toc" id="status">Status of this document</h2>
98 <!--status-->
100 <p>The following features are at risk: …
102 <h2 class="no-num no-toc" id="contents">
103 Table of Contents</h2>
105 <!--toc-->
107 <h2 id="intro">
108 Introduction</h2>
110 <p><em>This section is not normative.</em>
112 <h3 id="placement">
113 Module interactions</h3>
115 <p>This module extends the inline box model of CSS Level 2 [[!CSS21]]
116 to support ruby.
118 <p>None of the properties in this module apply to the <code>::first-line</code> or
119 <code>::first-letter</code> pseudo-elements.
121 <h3 id="values">
122 Values</h3>
124 <p>This specification follows the
125 <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
126 definition conventions</a> from [[!CSS21]]. Value types not defined in
127 this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
128 Other CSS modules may expand the definitions of these value types: for
129 example [[CSS3VAL]], when combined with this module, expands the
130 definition of the <var><length></var> value type as used in this specification.</p>
132 <p>In addition to the property-specific values listed in their definitions,
133 all properties defined in this specification also accept the
134 <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
135 keyword as their property value. For readability it has not been repeated
136 explicitly.
138 <h3 id="conventions">
139 Document conventions</h3>
141 <p>Many typographical conventions in East Asian typography depend
142 on whether the character rendered is wide (CJK) or narrow (non-CJK).
143 There are a number of illustrations in this document
144 for which the following legend is used:
146 <dl>
147 <dt><img alt="Symbolic wide-cell glyph representation" width="39" height="39" src="images/fullwidth.gif">
148 <dd>Wide-cell glyph (e.g. Han) that is the <var>n</var>th character in the text run.
149 They are typically sized to 50% when used as annotations.
150 <dt><img alt="Symbolic narrow-cell glyph representation" width="19" height="39" src="images/halfwidth.gif">
151 <dd>Narrow-cell glyph (e.g. Roman) which is the <var>n</var>th glyph in the text run.
152 </dl>
154 <p>The orientation which the above symbols assume in the diagrams
155 corresponds to the orientation that the glyphs they represent
156 are intended to assume when rendered by the user agent.
157 Spacing between these characters in the diagrams is incidental,
158 unless intentionally changed to make a point.
160 <h3 id="ruby-def">
161 What is ruby?</h3>
163 <p><dfn>Ruby</dfn> is the commonly-used name for a run of text
164 that appears alongside another run of text (referred to as the “base”)
165 and serves as an annotation or a pronunciation guide associated with that run of text.
167 <p>The following figures show two examples of Ruby,
168 a simple case and one with more complicated structure.
170 <div class="example">
171 <p>In this first example, a single annotation is used to annotate the base text.
172 <div class="figure">
173 <p><img src="images/licence.png"
174 alt="Example of ruby applied on top of a Japanese expression">
175 <p class="caption">Example of ruby used in Japanese (simple case)
176 </div>
177 <p>In Japanese typography, this case is sometimes called
178 <i lang="ja">taigo</i> ruby or group-ruby (per-word ruby),
179 because the annotation as a whole is associated
180 with multi-character word (as a whole).
181 </div>
183 <div class="example">
184 <p>In this second example,
185 two levels of annotations are attached to a base sequence:
186 the hiragana characters on top refer to the pronunciation of each of the base kanji characters,
187 while the words “Keio” and “University” on the bottom are annotations describing the English translation.
188 <div class="figure">
189 <p><img src="images/ruby-univ.gif"
190 alt="Example showing complex ruby with annotation text over and under the base characters">
191 <p class="caption">Complex ruby with annotation text over and under the base characters
192 </div>
193 <p>
194 <p>Notice that to allow correct association between the hiragana characters and
195 their corresponding Kanji base characters,
196 the spacing between these Kanji characters is adjusted.
197 (This happens around the fourth Kanji character in the figure above.)
198 To avoid variable spacing between the Kanji characters in the example above
199 the hiragana annotations can be styled as a <i>collapsed annotation</i>,
200 which will look more like the group-ruby example earlier.
201 However because the base-annotation pairings are recorded in the ruby structure,
202 if the text breaks across lines, the annotation characters will stay
203 correctly paired with their respective base characters.
204 </div>
206 <p><i>Ruby</i> formatting as used in Japanese is described in JIS X-4051 [[JIS4051]] (in Japanese)
207 and in Requirements for Japanese Text Layout [[JLREQ]] (in English and Japanese)].
208 In HTML, ruby structure and markup to represent it is described
209 in the Ruby Markup Extension specification.
210 This module describes the CSS rendering model
211 and formatting controls relevant to ruby layout of such markup.
213 <h2 id="ruby-model">
214 Ruby Formatting Model</h2>
216 <p>The CSS ruby model is based on
217 the <a href="http://darobin.github.io/html-ruby/">HTML Ruby Markup Extension</a>
218 and <a href="http://www.w3.org/TR/ruby/">XHTML Ruby Annotation Recommendation</a> [[RUBY]].
219 In this model, a ruby structure consists of
220 one or more <dfn>ruby base</dfn> elements representing the base (annotated) text,
221 associated with one or more levels of <dfn>ruby annotation</dfn> elements representing the annotations.
222 The structure of ruby is similar to that of a table:
223 there are “rows” (the base text level, each annotation level)
224 and “columns” (each <i>ruby base</i> and its corresponding <i>ruby annotations</i>).
226 <p>Consecutive bases and annotations are grouped together into <dfn>ruby segments</dfn>.
227 Within a <i>ruby segment</i>, a <i>ruby annotation</i> may span multiple <i>ruby bases<i>.
229 <p class="note">In HTML, a single <code><ruby></code> element may contain multiple <i>ruby segments</i>.
230 (In the XHTML Ruby model, a single <code><ruby></code> element can only contain one <i>ruby segment</i>.)
232 <h3 id="ruby-display">
233 Ruby-specific 'display' property values</h3>
235 <p>For document languages (such as XML applications) that do not have pre-defined ruby elements,
236 authors must map document language elements to ruby elements;
237 this is done with the 'display' property.
239 <table class="propdef">
240 <tr>
241 <th>Name:
242 <td>display
243 <tr>
244 <th><a href="#values">New Values</a>:
245 <td>ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container
246 </table>
248 <p>The following new 'display' values assign ruby layout roles to an arbitrary element:
250 <dl>
251 <dt>''ruby''
252 <dd>Specifies that an element generates a <dfn title="ruby container | ruby container box">ruby container box</dfn>.
253 (Corresponds to HTML/XHTML <code><ruby></code> elements.)
254 <dt>''ruby-base''
255 <dd>Specifies that an element generates a <dfn title="ruby base box | ruby base">ruby base box</dfn>.
256 (Corresponds to HTML/XHTML <code><rb></code> elements.)
257 <dt>''ruby-text''
258 <dd>Specifies that an element generates a <dfn title="ruby annotation box | ruby annotation">ruby annotation box</dfn>.
259 (Corresponds to HTML/XHTML <code><rt></code> elements.)
260 <dt>''ruby-base-container''
261 <dd>Specifies that an element generates a <dfn title="ruby base container box | ruby base container">ruby base container box</dfn>.
262 (Corresponds to XHTML <code><rbc></code> elements; always implied in HTML.)
263 <dt>''ruby-text-container''
264 <dd>Specifies that an element generates a <dfn title="ruby annotation container box | ruby annotation container">ruby annotation container box</dfn>.
265 (Corresponds to HTML/XHTML <code><ruby></code> elements.)
266 </dl>
268 <h3 id="box-fixup">
269 Anonymous Ruby Box Generation</h3>
271 <p>The CSS model does not require that the document language
272 include elements that correspond to each of these components.
273 Missing parts of the structure are implied through the anonymous box generation rules
274 <a href="http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes">similar to those used to normalize tables</a>. [[!CSS21]]
276 <ol>
277 <li>Any in-flow block-level boxes directly contained by a
278 <i>ruby container</i>,
279 <i>ruby base container</i>,
280 <i>ruby annotation container</i>,
281 <i>ruby base box</i>,
282 or <i>ruby annotation box</i>
283 are forced to be inline-level boxes,
284 and their 'display' value computed accordingly.
285 For example,
286 the 'display' property of an in-flow element with ''display: block''
287 parented by an element with ''display: ruby-text''
288 computes to ''inline-block''.
289 This computation occurs after any intermediary anonymous-box fixup
290 (such as that required by internal table elements).
292 <li>Any consecutive sequence of <i>ruby bases</i> not parented by a <i>ruby base container</i>
293 is wrapped in an anonymous <i>ruby base container</i>.
294 Similarly, any consecutive sequence of <i>ruby annotations</i> not parented by a <i>ruby annotation container</i>
295 is wrapped in an anonymous <i>ruby annotation container</i>.
297 <li>Within each <i>ruby base container</i>,
298 each sequence of inline-level boxes is wrapped in an anonymous <i>ruby base box</i>.
299 Similarly, within each <i>ruby annotation container</i>,
300 each sequence of inline-level boxes is wrapped in an anonymous <i>ruby annotation box</i>.
302 <li>A sequence of <i>ruby base containers</i> and/or <i>ruby annotation containers</i>
303 not parented by a <i>ruby container</i>
304 is wrapped in an anonymous <i>ruby container</i>.
305 </ol>
307 <p>At this point, all ruby layout structures are properly parented,
308 and the UA can start to associate bases with their annotations.
310 <p class="note">
311 Note that the UA is not required to create any of these anonymous boxes in its internal structures,
312 as long as pairing and layout behaves as if they existed.
314 <h3 id="pairing">
315 Ruby Pairing and Annotation Levels</h3>
317 <p>Within a ruby structure,
318 each <i>ruby base</i> is associated with <i>ruby annotations</i>
319 and vice versa.
320 A <i>ruby base</i> can be associated with at most one <i>ruby annotation</i> per annotation level.
321 If there are multiple annotation levels, it can therefore be associated with multiple <i>ruby annotations</i>.
322 A <i>ruby annotation</i> is associated with one or more <i>ruby bases</i>;
323 annotations can span multiple bases.
325 <p><dfn>Annotation pairing</dfn> is the process of associating
326 <i>ruby annotations</i> with <i>ruby bases</i>.
328 <ol>
329 <li>
330 <p>First, the ruby structure is divided into <i>ruby segments</i>,
331 each consisting of a single <i>ruby base container</i>
332 followed by one or more <i>ruby annotation containers</i>.
333 If the first child of a <i>ruby container</i> is a <i>ruby annotation container</i>,
334 an anonymous, empty <i>ruby base container</i> is assumed to exist before it.
335 Similarly, if the <i>ruby container</i> contains consecutive <i>ruby base containers</i>,
336 anonymous, empty <i>ruby annotation containers</i> are assumed to exist between them.
337 The <i>ruby base container</i> in each segment is thus associated
338 with each of the <i>ruby annotation containers</i> in that segment.
340 <p>Each <i>ruby annotation containers</i> in a <i>ruby segment</i>
341 represents one <dfn title="annotation level | level">level</dfn> of annotation:
342 the first one represents the first level of annotation,
343 the second one represents the second level of annotation,
344 and so on.
346 <li>Within each <i>ruby segment</i>,
347 each <i>ruby base box</i> in the <i>ruby base container</i>
348 is paired with one <i>ruby annotation box</i>
349 from each <i>ruby annotation container</i> in its <i>ruby segment</i>.
350 If there are not enough <i>ruby annotations</i> in a <i>ruby annotation container</i>,
351 the last one is associated with any excess <i>ruby bases</i>.
352 (If there are not any in the <i>ruby annotation container</i>, an anonymous empty one is assumed to exist.)
353 If there are not enough <i>ruby bases</i>,
354 any remaining <i>ruby annotations</i> are assumed to be associated
355 with empty, anonymous bases inserted at the end of the <i>ruby base container</i>.
357 <p>If an implementation supports ruby markup with explicit spanning
358 (e.g. XHTML Complex Ruby Annotations),
359 it must adjust the pairing rules to pair spanning annotations to multiple bases
360 appropriately.
361 </ol>
363 <p>A this point, ruby “columns” are defined,
364 each represented by a single <i>ruby base</i>
365 and associated with one <i>ruby annotation</i> (possibly an empty, anonymous one)
366 from each <i>annotation level</i>.
368 <h4 id="nested-pairing">
369 Nested Ruby</h4>
371 <p>When <i>ruby containers</i> are nested,
372 pairing begins with the deepest <i>ruby container</i>,
373 then expands out,
374 treating each <i>ruby container</i> nested within another <i>ruby container</i>
375 as a <i>ruby base</i>,
376 and associating each <i>ruby annotation</i>
377 associated with the nested <i>ruby container</i>
378 as being associated with (spanning) all of its <i>ruby bases</i>.
380 <p>Using nested <i>ruby containers</i> thus allows the representation
381 of complex spanning relationships.
383 <p class="issue">This shouldn't belong in Level 1. But HTML5 allows it, so we have to handle it. Yay HTML5.
385 <h3 id="autohide">
386 Autohiding Annotations</h3>
388 <p>If a <i>ruby annotation</i> has the exact same content as its base,
389 it is <dfn title="hidden ruby annotation | hidden annotation">hidden</dfn>.
390 Hiding a <i>ruby annotation</i> does not affect annotation pairing
391 or the block-axis positioning of boxes in other <i>levels</i>.
392 However the <i>hidden annotation</i> is not visible,
393 and it has no impact on layout
394 other than to separate adjacent sequences of <i>ruby annotation boxes</i> within its level,
395 as if they belonged to separate segments
396 and the <i>hidden annotation</i>’s base were not a <i>ruby base</i> but an intervening inline.
398 <div class="example">
399 <p>This is to allow correct inlined display of annotations
400 for Japanese words that are a mix of kanji and hirangana.
401 For example, the word <i>振り仮名</i> should be inlined as
402 <p class="figure">振り仮名(ふりがな)
403 <p>and therefore marked up as
404 <pre>
405 <!-- --><ruby>
406 <!-- --> <rb>振</rb><rb>り</rb><rb>仮</rb><rb>名</rb>
407 <!-- --> <rp>(</rp><rt>ふ</rt><rt>り</rt><rt>が</rt><rt>な</rt><rp>)</rp>
408 <!-- --><ruby></pre>
409 <p>However, when displayed as ruby, the “り” should be hidden
410 <div class="figure">
411 <p><img src="images/furigana-separate.png"
412 alt="Hiragana annotations for 振り仮名 appear, each above its base character.">
413 <p class="caption">Hiragana ruby for 振り仮名
414 </div>
415 </div>
417 <p class="note">
418 Future levels of CSS Ruby may add controls for this,
419 however in this level it is always forced.
421 <p>The content comparison for this auto-hiding behavior
422 takes place prior to white space collapsing.
423 <span class="issue">Is this easier? Or after collapsing is easier? We should do whatever is easier, as it really doesn't matter much which way to go.
425 <h3 id="white-space">
426 White Space</h3>
428 <p class="issue">I'm unsure exactly where space should be trimmed. :/
429 But pretty sure we need to keep spaces between things,
430 otherwise ruby only works for CJK.
432 <p><i>Collapsible</i> white space within a ruby structure is discarded
433 at the beginning and end of a <i>ruby container</i>,
434 and at the beginning/end of a <i>ruby annotation box</i> or <i>ruby base box</i> if white space is not its only contents.
435 Between <i>ruby segments</i>, between <i>ruby bases</i>, and between <i>ruby annotations</i>, however,
436 white space is not discarded.
437 If such white space is <i>collapsible</i>, it will collapse
438 following the standard <a href="http://www.w3.org/TR/css3-text/#white-space-rules">white space processing rules</a>. [[!CSS3TEXT]]
439 Between <i>ruby segments</i>, however,
440 the contextual text for determining collapsing behavior is given by the <i>ruby bases</i> on either side,
441 not the text on either side of the white space in the source document.
443 <div class="note">
444 <p>Note that the white space processing rules
445 cause a white space sequence containing a <i>segment break</i> (such as a line feed)
446 to <a href="http://www.w3.org/TR/css3-text/#line-break-transform">collapse to nothing</a> between CJK characters.
447 This means that CJK ruby can safely use white space for indentation of the ruby markup.
448 For example, the following markup will display without any spaces:
449 <pre>
450 <!-- --><ruby>
451 <!-- --> <rb>東</rb><rb>京</rb>
452 <!-- --> <rt>とう</rt><rt>きょう</rt>
453 <!-- --></ruby></pre>
454 <p>However, this markup will:
455 <pre>
456 <!-- --><ruby>
457 <!-- --> <rb>東</rb> <rb>京</rb>
458 <!-- --> <rt>とう</rt> <rt>きょう</rt>
459 <!-- --></ruby></pre>
460 </div>
462 <p>Any preserved white space is then wrapped in an anonymous box belonging to
463 the <i>ruby base container</i> (if between <i>ruby bases</i>),
464 <i>ruby annotation container</i> (if between <i>ruby annotations</i>),
465 or <i>ruby container</i> (if between <i>ruby segments</i>).
466 In the latter case, the text is considered part of the <i>base level</i>.
467 This box does not take part in pairing.
468 It merely ensures separation between adjacent bases/annotations.
470 <div class="example">
471 <p>These rules allow ruby to be used with space-separated scripts such as Latin.
472 For example,
473 <pre>
474 <!-- --><ruby>
475 <!-- --> <rb>W</rb><rb>W</rb><rb>W</rb>
476 <!-- --> <rt>World</rt> <rt>Wide</rt> <rt>Web</rt>
477 <!-- --></ruby></pre>
478 <p>They also ensure that annotated white space is preserved. For example,
479 <pre>
480 <!-- --><ruby>
481 <!-- --> <rb>Aerith</rb><rb> </rb><rb>Gainsboro</rb>
482 <!-- --> <rt>エアリス</rt><rt>・</rt><rt>ゲインズブール</rt>
483 <!-- --></ruby></pre>
484 </div>
486 <p class="issue">Specify how this impacts layout, or not.
488 <h3 id="ruby-layout">
489 Ruby layout</h3>
491 <p>When a ruby structure is laid out,
492 its base level is laid out on the line,
493 aligned according to its 'vertical-align' property
494 exactly as if it were a regular sequence of <i>inline</i> boxes.
495 Each <i>ruby base container</i> is sized and positioned
496 to contain exactly the full height of its <i>ruby bases</i>.
498 <p><i>Ruby annotations</i> associated with the base level
499 are then positioned with respect to their <i>ruby base boxes</i>
500 according to the applicable 'ruby-position' values.
501 <i>Ruby annotations</i> within a level (within a single <i>ruby container</i>)
502 are aligned to each other as if they were inline boxes
503 participating in the same inline formatting context.
504 Each <i>ruby annotation container</i> is sized and positioned
505 to contain exactly the full height of its <i>ruby annotations</i>.
507 <p>A ruby container (or fragment thereof)
508 measures as wide as the content of its widest level.
509 (In the case of ''inter-character'' annotations,
510 they are spliced in and measured as part of the base level.)
511 Similarly, <i>ruby base boxes</i> and <i>ruby annotation boxes</i>
512 within a ruby “column” have the measure of the widest content in that “column”.
513 In the case of spanning <i>annotations</i>
514 (whether actually spanning or pretending to span per 'ruby-collapse'),
515 the measures of the <i>ruby annotation box</i> and
516 the sum of its associated <i>ruby base boxes</i> must match.
518 <p>How the extra space is distributed
519 when ruby content is narrower than the measure of its box
520 is specified by the 'ruby-align' property.
522 <h3 id="line-breaking">
523 Ruby box and line breaking</h3>
525 <p>When there is not enough space for an entire <i>ruby container</i> to fit on the line,
526 the ruby may be broken wherever all levels allow a break.
527 In typical cases, line breaks are forbidden within each <i>ruby base</i> and <i>ruby annotation</i>,
528 so the <i>ruby container</i> can only break between adjacent <i>ruby bases</i>,
529 and only if no <i>ruby annotations</i> span those <i>ruby bases</i>.
530 Whenever ruby breaks across lines, <i>ruby annotations</i>
531 <em>must</i> stay with their respective bases.
533 <div class="figure">
534 <p><img src="images/r-break-a.gif"
535 alt="Diagram showing the line breaking opportunity in a complex ruby">
536 <p class="caption">Ruby line breaking opportunity
537 </div>
539 <p>Whether ruby can break between two adjacent <i>ruby bases</i>
540 is controlled by normal line-breaking rules for the affected text,
541 exactly as if the <i>ruby bases</i> were regular <i>inline</i> boxes.
543 <div class="example">
544 <p>For example, if two adjacent ruby bases are “蝴” and “蝶”,
545 the line may break between them,
546 because lines are normally allowed to break between two Han characters.
547 However, if 'word-break' is ''keep-all'', that line break is forbidden.
548 </div>
550 <p>Inter-base white space is significant for evaluating line break opportunities between <i>ruby bases</i>.
551 As with white space between inlines, it collapses when the line breaks there.
553 <div class="example">
554 <p>For example, given the following markup:
555 <pre><ruby><rb>one</rb> <rb>two</rb> <rt>1</rt> <rt>2</rt></ruby></pre>
556 <p>Due to the space, the line may break between “one” and “two“.
557 If the line breaks there, that space disappears,
558 in accordance with standard CSS white space processing rules. [[CSS3-TEXT]]
559 </div>
561 <p>The line <em>must not</em> break between a <i>ruby base</i> and its annotations.
563 <div class="figure">
564 <img src="images/r-break-b.gif"
565 alt='Diagram showing the line breaking opportunity in a "Bopomofo" ruby'>
566 <p class="caption">''inter-character'' ruby line breaking opportunity
567 </div>
569 <h3 id="line-height">
570 Ruby box and line stacking</h3>
572 <p>The 'line-height' property controls spacing between lines in CSS.
573 When inline content on line is shorter than the 'line-height',
574 half-leading is added on either side of the content,
575 as specificed in <a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">CSS2.1§10.8</a>. [[!CSS21]]
577 <p>In order to ensure consistent spacing of lines,
578 documents with ruby typically ensure that the 'line-height' is large enough
579 to accommodate ruby between lines of text.
580 Therefore, ordinarily, <i>ruby annotation containers</i> and <i>ruby annotation boxes</i>
581 do not contribute to the measured height of a line's inline contents;
582 any alignment (see 'vertical-align') and line-height calculations
583 are performed using only the <i>ruby base container</i>,
584 exactly as if it were a normal inline.
586 <p>However, if the 'line-height' specified on the <i>ruby container</i>
587 is less than the distance between
588 the top of the top <i>ruby annotation container</i>
589 and the bottom of the bottom <i>ruby annotation container</i>,
590 then additional leading is added
591 on the appropriate side of the <i>ruby base container</i>
592 such that if a block consisted of three lines
593 each containing ruby identical to this,
594 none of the <i>ruby containers</i> would overlap.
596 <p class="note">Note that this does not ensure that the <i>ruby annotations</i> remain within the line box.
597 It merely ensures that <em>if all lines had equal spacing</em>
598 and equivalent amounts and positioning of <i>ruby annotations</i>,
599 there would be enough room to avoid overlap.
601 <p>Authors should ensure appropriate 'line-height' and 'padding' to accommodate ruby,
602 and be particularly careful at the beginning or end of a block
603 and when a line contains inline-level content
604 (such as images, inline blocks, or elements shifted with 'vertical-align')
605 taller than the paragraph's default font size.
607 <div class="figure">
608 <p><img src="images/rlh-a.gif"
609 alt="The content of each line sits in the middle of its line height;
610 the additional space on each side is called half-leading.
611 Ruby fits between lines if it is smaller than twice the half-leading,
612 but this means that it occupies space belonging to the half-leading of the previous line.">
613 <p class="caption">Ruby annotations will often overflow the line;
614 authors should ensure content over/under a ruby-annotated line
615 is adequately spaced to leave room for the ruby.
616 </div>
618 <p class="note">More control over how ruby affects alignment and line layout
619 will be part of the CSS Line Layout Module Level 3.
620 Note, it is currently in the process of being rewritten;
621 the current drafts should not be relied upon.
623 <h2 id="ruby-props">
624 Ruby Properties</h2>
626 <p>The following properties are introduced to control ruby positioning and alignment.
628 <h3 id="rubypos">
629 Ruby positioning: the 'ruby-position' property</h3>
631 <table class="propdef">
632 <tr>
633 <th>Name:
634 <td><dfn>ruby-position</dfn>
635 <tr>
636 <th><a href="#values">Value</a>:
637 <td>[ over | under | inter-character ] && [ right | left ]
638 <tr>
639 <th>Initial:
640 <td>over right
641 <tr>
642 <th>Applies to:
643 <td>ruby annotation containers
644 <tr>
645 <th>Inherited:
646 <td>yes
647 <tr>
648 <th>Percentages:
649 <td>N/A
650 <tr>
651 <th>Media:
652 <td>visual
653 <tr>
654 <th>Computed value:
655 <td>specified value
656 <tr>
657 <th>Animatable:
658 <td>no
659 <tr>
660 <th>Canonical order:
661 <td><abbr title="follows order of property value definition">per grammar</abbr>
662 </table>
664 <p>This property controls position of the ruby text with respect to its base.
665 Values have the following meanings:
667 <p class="issue"><span class="issuehead">Issue-107: </span> Roland Steiner has requested the addition of an auto value as default. See <a href="http://www.w3.org/Search/Mail/Public/advanced_search?keywords=&hdr-1-name=subject&hdr-1-query=ruby-position%3A+undesirable+default+value+%27before%27+for+complex+ruby&hdr-2-name=from&hdr-2-query=&hdr-3-name=message-id&hdr-3-query=&period_month=&period_year=&index-grp=Public__FULL&index-type=t&type-index=www-style&resultsperpage=20&sortby=date">this thread</a> and <a href="http://www.w3.org/Search/Mail/Public/advanced_search?keywords=&hdr-1-name=subject&hdr-1-query=Styling+of+complex+Ruby&hdr-2-name=from&hdr-2-query=&hdr-3-name=message-id&hdr-3-query=&period_month=&period_year=&index-grp=Public__FULL&index-type=t&type-index=public-i18n-core&resultsperpage=20&sortby=date">this one</a>.</p>
668 <dl>
669 <dt><dfn title="ruby-position:over">''over''</dfn>
670 <dd>The ruby text appears <i>over</i> the base in horizontal text.
672 <div class="figure">
673 <p><img src="images/shinkansen-top.gif"
674 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing above the base">
675 <p class="caption">Ruby over Japanese base text in horizontal layout
676 </div>
677 </dd>
679 <dt><dfn title="ruby-position:right">''right''</dfn>
680 <dd>The ruby text appears on the right side of the base in vertical text.
681 <div class="figure">
682 <p><img src="images/shinkansen-right.gif" width="33"
683 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the right of the base">
684 <p class="caption">Ruby to the right of Japanese base text in vertical layout
685 </div>
686 </dd>
688 <dt><dfn title="ruby-position:under">''under''</dfn>
689 <dd>The ruby text appears under the base in horizontal text.
690 This is a relatively rare setting used in ideographic East Asian writing systems,
691 most easily found in educational text.
693 <div class="figure">
694 <p><img src="images/shinkansen-bottom.gif"
695 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing below the base">
696 <p class="caption">Ruby under Japanese base text in horizontal layout
697 </div>
698 </dd>
700 <dt><dfn title="ruby-position:left">''left''</dfn>
701 <dd>The ruby text appears on the left side of the base in vertical text.
703 <div class="figure">
704 <p><img src="images/shinkansen-left.gif"
705 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the left of the base">
706 <p class="caption">Ruby to the left of Japanese base text in vertical layout
707 </div>
708 </dd>
710 <dt><dfn title="ruby-position:inter-character">''inter-character''</dfn></dt>
711 <dd>
712 <p>The ruby text appears on the right of the base in horizontal text.
713 This value forces the 'writing-mode' of the <i>ruby annotation</i> to be vertical.
715 <p>This value is provided for the special case of traditional Chinese
716 as used especially in Taiwan:
717 ruby (made of <a href="#g-bopomofo">bopomofo</a> glyphs) in that context
718 appears vertically along the right side of the base glyph,
719 even when the layout of the base characters is horizontal:
721 <div class="figure">
722 <p><img src="images/bopomofo.gif"
723 alt="Example of Taiwanese-style ruby">
724 <p class="caption">“Bopomofo” ruby in traditional Chinese
725 (ruby text shown in blue for clarity) in horizontal layout
726 </div>
727 <p class="note">
728 Note that the user agent is responsible for ensuring the correct relative alignment and positioning of the glyphs,
729 including those corresponding to the tone marks, when displaying.
730 Tone marks are spacing characters that occur (in memory) at the end of the ruby text for each base character.
731 They are usually displayed in a separate column to the right of the bopomofo characters,
732 and the height of the tone mark depends on the number of characters in the syllable.
733 One tone mark, however, is placed above the bopomofo, not to the right of it.
734 <!-- See Taiwanese requirements doc for EPUB at http://epub-revision.googlecode.com/files/EGLS_TW_eng.ppt -->
735 </dd>
736 </dl>
738 <p>If multiple <i>ruby annotation containers</i> have the same 'ruby-position',
739 they stack along the block axis,
740 with lower levels of annotation closer to the base text.
742 <h3 id="collapsed-ruby">
743 Collapsed Ruby Annotations: the 'ruby-merge' property</h3>
745 <table class="propdef">
746 <tr>
747 <th>Name:
748 <td><dfn>ruby-merge</dfn>
749 <tr>
750 <th><a href="#values">Value</a>:
751 <td>separate | collapse | auto
752 <tr>
753 <th>Initial:
754 <td>separate
755 <tr>
756 <th>Applies to:
757 <td>ruby annotation containers
758 <tr>
759 <th>Inherited:
760 <td>yes
761 <tr>
762 <th>Percentages:
763 <td>N/A
764 <tr>
765 <th>Media:
766 <td>visual
767 <tr>
768 <th>Computed value:
769 <td>specified value
770 <tr>
771 <th>Animatable:
772 <td>no
773 <tr>
774 <th>Canonical order:
775 <td><abbr title="follows order of property value definition">per grammar</abbr>
776 </table>
778 <p>
779 This property controls how ruby annotation boxes should be rendered
780 when there are more than one in a ruby container box.
782 <p>Possible values:</p>
783 <dl>
784 <dt><dfn title="ruby-merge:separate">''separate''</dfn>
785 <dd>
786 <p>
787 Each ruby annotation box is rendered in the same column(s) as its corresponding base box(es).
788 This style is called “mono ruby” in [[JLREQ]].
790 <div class="example">
791 <p>For example, the following two markups render the same:
792 <pre><ruby>無<rt>む</ruby><ruby>常<rt>じょう</ruby></pre>
793 <p>and:
794 <pre><ruby style="ruby-merge:separate"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
795 </div>
796 </dd>
798 <dt><dfn title="ruby-merge:collapse">''collapse''</dfn>
799 <dd>
800 <p>
801 All <i>ruby annotation boxes</i> within the same <i>ruby segment</i> on the same line are concatenated,
802 and laid out as if their contents belonged to a single <i>ruby annotation box</i>
803 spanning all their associated <i>ruby base boxes.
804 This style renders similar to “group ruby” in [[JLREQ]],
805 except that <i>ruby annotations</i> are kept together with their respective <i>ruby bases</i> when breaking lines.
806 </p>
808 <div class="example">
809 <p>The following two markups render the same both characters fit on one line:
810 <pre><ruby>無常<rt>むじょう</ruby></pre>
811 <p>and:
812 <pre><ruby style="ruby-merge:collapse"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
813 <p>However, the second one renders the same as ''ruby-position: separate''
814 when the two bases are split across lines.
815 </div>
816 </dd>
818 <dt><dfn title="ruby-merge:auto">''auto''</dfn></dt>
819 <dd>
820 <p>
821 The user agent may use any algorithm to determine how each ruby annotation box
822 is rendered to its corresponding base box.
823 <div class="example">
824 <p>
825 One possible algorithm is described as Jukugo-ruby in [[JLREQ]].
826 <p>
827 Another, more simplified algorithm of Jukugo-ruby is
828 to render as Mono-ruby if all ruby annotation boxes fit within
829 advances of their corresponding base boxes,
830 and render as Group-ruby otherwise.
831 </p>
832 </div>
833 </dd>
834 </dl>
836 <h3 id="rubyalign">
837 Ruby Text Distribution: the 'ruby-align' property</h3>
839 <table class="propdef">
840 <tr>
841 <th>Name:
842 <td><dfn>ruby-align</dfn>
843 <tr>
844 <th><a href="#values">Value</a>:
845 <td>auto | start | center |
846 distribute-letter | distribute-space
847 <tr>
848 <th>Initial:
849 <td>auto
850 <tr>
851 <th>Applies to:
852 <td>ruby bases, ruby annotations, ruby base containers, ruby annotation containers
853 <tr>
854 <th>Inherited:
855 <td>yes
856 <tr>
857 <th>Percentages:
858 <td>N/A
859 <tr>
860 <th>Media:
861 <td>visual
862 <tr>
863 <th>Computed value:
864 <td>specified value (except for initial and inherit)
865 </table>
867 <p>This property specifies how text is distributed within the various ruby boxes
868 when their text contents exactly fill their respective boxes.
870 <p>Values have the following meanings:
871 <p class="issue"><span class="issuehead">Issue: </span> Tony Graham has <a href="http://www.w3.org/Style/XSL/Group/FO/wiki/Ruby#Treat_CSS3_.22ruby-align.22_As_Shorthand.3F">suggested </a>that distribute-letter and distribute-space be values of a ruby-group-distribution property, and line-edge be moved to a ruby-alignment-edge property, and that the rest be gathered under a ruby-alignment property. And that ruby-align become a shorthand.</p>
872 <dl>
873 <dt><dfn title="ruby-align:auto">''auto''</dfn></dt>
874 <dd>
875 <p>The user agent determines how the ruby contents are aligned.
876 This is the initial value.
877 The behavior recommended by [[JLREQ]] is for wide-cell ruby to be aligned in the 'distribute-space' mode:
878 <div class="figure">
879 <p><img width="145" height="91"
880 alt="Diagram of glyph layout in auto aligned ruby when ruby text is shorter than base"
881 src="images/ra-ds.gif" /><img width="145" height="91"
882 alt="Diagram of glyph layout in auto aligned ruby when ruby text is longer than base"
883 src="images/ra-ds-rb.gif" /></p>
884 <p><b>Figure 4.2.1</b>: Wide-cell text in 'auto' ruby alignment is
885 'distribute-space' justified</p>
886 </div>
888 <p>The recommended behavior for narrow-cell glyph ruby is to be
889 aligned in the 'center' mode.</p>
890 <div class="figure">
891 <p><img
892 alt="Diagram of glyph layout in auto aligned ruby when halfwidth ruby text is shorter than base"
893 width="145" height="91"
894 src="images/ra-c-h.gif" /><img
895 alt="Diagram of character layout in auto aligned ruby when ruby text is longer than narrow-width base"
896 width="145" height="91"
897 src="images/ra-c-rb-h.gif" /></p>
898 <p><b>Figure 4.2.2</b>: Narrow-width ruby text in 'auto' ruby alignment
899 is centered</p>
900 </div>
901 </dd>
903 <dt><dfn title="ruby-align:start">''start''</dfn></dt>
904 <dd>The ruby annotation content is aligned with the start edge of the base.
905 <div class="figure">
906 <p><img
907 alt="Diagram of glyph layout in left aligned ruby when ruby text is shorter than base"
908 width="145" height="91" src="images/ra-l.gif" /><img
909 width="145" height="91"
910 alt="Diagram of glyph layout in left aligned ruby when ruby text is longer than base"
911 src="images/ra-l-rb.gif" /></p>
912 <p><b>Figure 4.2.3</b>: Start ruby alignment</p>
913 </div>
914 </dd>
916 <dt><dfn title="ruby-align:center">''center''</dfn></dt>
917 <dd>The ruby text content is centered within the width of the base. If the
918 length of the base is smaller than the length of the ruby text, then the
919 base is centered within the width of the ruby text.
921 <div class="figure">
922 <p><img width="145" height="91"
923 alt="Diagram of glyph layout in center aligned ruby when ruby text is shorter than base"
924 src="images/ra-c.gif" /><img width="145" height="91"
925 alt="Diagram of glyph layout in center aligned ruby when ruby text is longer than base"
926 src="images/ra-c-rb.gif" /></p>
927 <p><b>Figure 4.2.4</b>: Center ruby alignment</p>
928 </div>
929 </dd>
931 <!--
932 <dt><strong>right</strong></dt>
933 <dd>The ruby text content is aligned with the end edge of the base.
934 <p class="issue"><span class="issuehead">Issue: </span> The i18n WG feels that end and right should not be synonymous, and proposed to drop right (there is no left/right in overhang)? See <a href="http://www.w3.org/Search/Mail/Public/advanced_search?keywords=&hdr-1-name=subject&hdr-1-query=[CSS3+Ruby]%20left/start+and+right/end&hdr-2-name=from&hdr-2-query=&hdr-3-name=message-id&hdr-3-query=&index-grp=Member__FULL+Public__FULL&index-type=t&type-index=public-i18n-core%40w3.org&resultsperpage=20&sortby=date">this thread</a>.</p>
935 <div class="figure">
936 <p><img class="example" width="145" height="91"
937 alt="Diagram of glyph layout in right aligned ruby when ruby text is shorter than base"
938 src="images/ra-r.gif" /><img class="example" width="145" height="91"
939 alt="Diagram of glyph layout in right aligned ruby when ruby text is longer than base"
940 src="images/ra-r-rb.gif" /></p>
941 <p><b>Figure 4.2.5</b>: End ruby alignment</p>
942 </div>
943 </dd>
944 -->
946 <dt><dfn title="ruby-align:distribute-letter">''distribute-letter''</dfn></dt>
947 <dd>If the width of the ruby text is smaller than that of the base, then
948 the ruby text contents are evenly distributed across the width of the
949 base, with the first and last ruby text glyphs lining up with the
950 corresponding first and last base glyphs. If the width of the ruby text
951 is at least the width of the base, then the letters of the base are
952 evenly distributed across the width of the ruby text.
954 <div class="figure">
955 <p><img width="145" height="91"
956 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is shorter than base"
957 src="images/ra-dl.gif" /><img width="145" height="91"
958 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is longer than base"
959 src="images/ra-dl-rb.gif" /></p>
960 <p><b>Figure 4.2.6</b>: Distribute-letter ruby alignment</p>
961 </div>
962 </dd>
964 <dt><dfn title="ruby-align:distribute-space">''distribute-space''</dfn></dt>
965 <dd>If the width of the ruby text is smaller than that of the base, then
966 the ruby text contents are evenly distributed across the width of the
967 base, with a certain amount of white space preceding the first and
968 following the last character in the ruby text. That amount of white
969 space is normally equal to half the amount of inter-character space of
970 the ruby text. If the width of the ruby text is at least the width of
971 the base, then the same type of space distribution applies to the base.
972 In other words, if the base is shorter than the ruby text, the base is
973 distribute-space aligned. This type of alignment
974 is described by [[JLREQ]].
976 <div class="figure">
977 <p><img width="145" height="91"
978 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is shorter than base"
979 src="images/ra-ds.gif" /><img width="145" height="91"
980 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is longer than base"
981 src="images/ra-ds-rb.gif" /></p>
982 <p><b>Figure 4.2.7</b>: Distribute-space ruby alignment</p>
983 </div>
984 </dd>
986 <!--
987 <dt><strong>line-edge</strong></dt>
988 <dd>If the ruby text is not adjacent to a line edge, it is aligned as in
989 'auto'. If it is adjacent to a line edge, then it is still aligned as in
990 auto, but the side of the ruby text that touches the end of the line is
991 lined up with the corresponding edge of the base. This type of alignment
992 is described by [[JLREQ]]. This type of alignment is
993 relevant only to the scenario where the ruby text is longer than the
994 ruby base. In the other scenarios, this is just 'auto'.
995 <div class="figure">
996 <p><img class="example" width="146" height="109"
997 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base"
998 src="images/ra-le-l.gif" /><img class="example" width="146"
999 height="110"
1000 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base"
1001 src="images/ra-le-r.gif" /></p>
1002 <p><b>Figure 4.2.8</b>: Line edge ruby alignment</p>
1003 </div>
1004 </dd>
1005 -->
1006 </dl>
1008 <p>For a complex ruby with spanning elements, one additional consideration is
1009 required. If the spanning element spans multiple 'rows' (other rbc or rtc
1010 elements), and the ruby alignment requires space distribution among the
1011 'spanned' elements, a ratio must be determined among the 'columns' of spanned
1012 elements. This ratio is computed by taking into consideration the widest
1013 element within each column.</p>
1015 <h2 id="edge-effects">
1016 Edge Effects</h2>
1018 <h3 id="ruby-overhang">
1019 Overhanging Ruby</h3>
1021 <p>
1022 When <i>ruby annotation box</i> is longer than its corresponding <i>ruby base box</i>,
1023 the <i>ruby annotation box</i> may partially overhang adjacent boxes.
1024 </p>
1025 <p>
1026 This level of the specification does not define
1027 how much the overhang may be allowed, and under what conditions.
1028 </p>
1030 <p>If the ruby text is not allowed to overhang,
1031 then the ruby behaves like a traditional inline box,
1032 i.e. only its own contents are rendered within its boundaries
1033 and adjacent elements do not cross the box boundary:
1035 <div class="figure">
1036 <p><img src="images/ro-n.gif"
1037 alt="Diagram showing the ruby boxes interacting with adjacent text">
1038 <p class="caption">Simple ruby whose text is not allowed to overhang adjacent text
1039 </div>
1041 <p>However, if <i>ruby annotation</i> content is allowed to overhang adjacent elements
1042 and it happens to be wider than its base,
1043 then the adjacent content is partially rendered within the area of the <i>ruby container box</i>,
1044 while the <i>ruby annotation</i> may partially overlap the upper blank parts of the adjacent content:
1046 <div class="figure">
1047 <p><img src="images/ro-a.gif"
1048 alt="Diagram showing the ruby boxes interacting with adjacent text">
1049 <p class="caption">Simple ruby whose text is allowed to overhang adjacent text
1050 </div>
1052 <p>The <i>ruby annotations</i> related to a <i>ruby base</i>
1053 must never overhang another <i>ruby base</i>.
1055 <p>The alignment of the contents of the base or the ruby text
1056 is not affected by overhanging behavior.
1057 The alignment is achieved the same way regardless of the overhang behavior setting
1058 and it is computed before the space available for overlap is determined.
1059 It is controlled by the 'ruby-align' property.
1061 <p class="issue">
1062 I suspect overhanging interacts with alignment in some cases;
1063 might need to look into this later.
1065 <p>This entire logic applies the same way in vertical ideographic layout,
1066 only the dimension in which it works in such a layout is vertical,
1067 instead of horizontal.
1069 <div class="example">
1070 <p>
1071 The user agent may use [[JIS4051]] recommendation of
1072 using one ruby text character length as the maximum overhang length.
1073 Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].
1074 </p>
1075 </div>
1077 <h3 id="line-edge">
1078 Line-edge Alignment</h3>
1080 <p>
1081 When a <i>ruby annotation box</i> that is longer than its <i>ruby base</i>
1082 is at the start or end edge of a line,
1083 the user agent <em>may</em> force the side of the <i>ruby annotation</i> that touches the edge of the line
1084 to align to the corresponding edge of the base.
1085 This type of alignment is described by [[JLREQ]].
1086 </p>
1087 <p>
1088 This level of the specification does not provide a mechanism to control this behavior.
1089 </p>
1090 <div class="figure">
1091 <p><img src="images/ra-le-l.gif"
1092 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base">
1093 <img src="images/ra-le-r.gif"
1094 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base">
1095 <p class="caption">Line-edge alignment
1096 </div>
1098 <!--
1099 <h3 id="rubyover">
1100 Ruby overhanging: the 'ruby-overhang' property</h3>
1102 <table class="propdef">
1103 <tr>
1104 <th>Name:
1105 <td><dfn>ruby-overhang</dfn>
1106 <tr>
1107 <th>Value:
1108 <td>auto | start | end | none
1109 <tr>
1110 <th>Initial:
1111 <td>none
1112 <tr>
1113 <th>Applies to:
1114 <td>the parent of elements with display: ruby-text
1115 <tr>
1116 <th>Inherited:
1117 <td>yes
1118 <tr>
1119 <th>Percentages:
1120 <td>N/A
1121 <tr>
1122 <th>Media:
1123 <td>visual
1124 <tr>
1125 <th>Computed value:
1126 <td>specified value (except for initial and inherit)
1127 </table>
1129 <p>This property determines whether, and on which side, ruby text is allowed
1130 to partially overhang any adjacent text in addition to its own base, when the
1131 ruby text is wider than the ruby base. Note that ruby text is never allowed to
1132 overhang glyphs belonging to another ruby base. <span class="issue"><span class="issuehead">Issue: </span> This rule must be broken if we are to allow support for jukugo ruby.</span> Also the user agent is free to assume
1133 a maximum amount by which ruby text may overhang adjacent text. The user agent may use
1134 the [[JIS4051]] recommendation of using one ruby text character
1135 length as the maximum overhang length. Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].</p>
1137 <p>Possible values:</p>
1138 <dl>
1139 <dt><strong>auto</strong></dt>
1140 <dd>The ruby text can overhang text adjacent to the base on either side. [[JLREQ]] and [[JIS4051]] specify the categories of characters that
1141 ruby text can overhang. The user agent is free to follow those recommendations or specify its own classes of
1142 characters to overhang. This is the initial value.
1143 <div class="figure">
1144 <p><img class="example" width="177" height="91"
1145 alt="Diagram of glyph layout in overhanging ruby" src="images/ro-a.gif" /></p>
1146 <p><b>Figure 4.3.1</b>: Ruby overhanging adjacent text</p>
1147 </div>
1148 </dd>
1149 <dt><strong>start</strong></dt>
1150 <dd>The ruby text can only overhang the text that precedes it. That means, for
1151 example, that ruby cannot overhang text that is to the right of it in
1152 horizontal LTR layout, and it cannot overhang text that is below it in
1153 vertical-ideographic layout.
1154 <div class="figure">
1155 <p><img class="example" width="199" height="91"
1156 alt="Diagram of glyph layout when ruby overhangs the preceding glyphs only"
1157 src="images/ro-s.gif" /></p>
1158 <p><b>Figure 4.3.2</b>: Ruby overhanging preceding text only</p>
1159 </div>
1160 </dd>
1161 <dt><strong>end</strong></dt>
1162 <dd>The ruby text can only overhang the text that follows it. That means, for
1163 example, that ruby cannot overhang text that is to the left of it in
1164 horizontal LTR layout, and it cannot overhang text that is above it in
1165 vertical-ideographic layout.
1166 <div class="figure">
1167 <p><img class="example" width="198" height="91"
1168 alt="Diagram of glyph layout when ruby overhangs the following characters only"
1169 src="images/ro-e.gif" /></p>
1170 <p><b>Figure 4.3.3</b>: Ruby overhanging following text only</p>
1171 </div>
1172 </dd>
1173 <dt><strong>none</strong></dt>
1174 <dd>The ruby text cannot overhang any text adjacent to its base, only its
1175 own base.
1177 <div class="figure">
1178 <p><img class="example" width="220" height="91"
1179 alt="Diagram of glyph layout in non-overhanging ruby"
1180 src="images/ro-n.gif" /></p>
1181 <p><b>Figure 4.3.4</b>: Ruby not allowed to overhang adjacent text</p>
1182 </div>
1183 </dd>
1184 </dl>
1186 <h3 id="rubyspan">
1187 Ruby annotation spanning: the 'ruby-span' property</h3>
1189 <table class="propdef">
1190 <tr>
1191 <th>Name:
1192 <td><dfn>ruby-span</dfn>
1193 <tr>
1194 <th>Value:
1195 <td>attr(x) | none
1196 <tr>
1197 <th>Initial:
1198 <td>none
1199 <tr>
1200 <th>Applies to:
1201 <td>elements with display: ruby-text
1202 <tr>
1203 <th>Inherited:
1204 <td>no
1205 <tr>
1206 <th>Percentages:
1207 <td>N/A
1208 <tr>
1209 <th>Media:
1210 <td>visual
1211 <tr>
1212 <th>Computed value:
1213 <td><number>
1214 </table>
1216 <p>This property controls the spanning behavior of annotation elements. </p>
1218 <p class="note"><span class="note-label">Note:</span> A XHTML user agent may also use the <samp>rbspan</samp>
1219 attribute to get the same effect.</p>
1221 <p>Possible values:</p>
1223 <dl>
1224 <dt><strong>attr(x)</strong></dt>
1225 <dd>The value of attribute 'x' as a string value. The string value is
1226 evaluated as a <number> to determine the number of ruby base elements to be
1227 spanned by the annotation element. If the <number> is '0', it is replaced by
1228 '1'.The <number> is the computed value. </dd>
1229 <dt>none</dt>
1230 <dd>No spanning. The computed value is '1'.</dd>
1231 </dl>
1233 <p>The following example shows an XML example using the 'display' property
1234 values associated with the 'ruby structure and the 'ruby-span' property</p>
1235 <pre class="xml">myruby { display: ruby; }
1236 myrbc { display: ruby-base-container; }
1237 myrb { display: ruby-base; }
1238 myrtc.before { display: ruby-text-container; ruby-position: before}
1239 myrtc.after { display: ruby-text-container; ruby-position: after}
1240 myrt { display: ruby-text; ruby-span: attr(rbspan); }
1241 ...
1242 <myruby>
1243 <myrbc>
1244 <myrb>10</myrb>
1245 <myrb>31</myrb>
1246 <myrb>2002</myrb>
1247 </myrbc>
1248 <myrtc class="before">
1249 <myrt>Month</myrt>
1250 <myrt>Day</myrt>
1251 <myrt>Year</myrt>
1252 </myrtc>
1253 <myrtc class="after">
1254 <myrt rbspan="3">Expiration Date</myrt>
1255 </myrtc>
1256 </myruby></pre>
1257 -->
1259 <h2 id="default-stylesheet" class="no-num">
1260 Appendix A: Default Style Sheet</h2>
1262 <p><em>This section is informative.</em>
1264 <h3 id="default-ua-ruby" class="no-num">
1265 <span class="secno">A.1</span> Supporting Ruby Layout</h3>
1267 <p>The following represents a default UA style sheet
1268 for rendering HTML and XHTML ruby markup as ruby layout:
1270 <pre>
1271 <!-- -->ruby { display: ruby; }
1272 <!-- -->rb { display: ruby-base; white-space: nowrap; }
1273 <!-- -->rt { display: ruby-text; white-space: nowrap; font-size: 50%; }
1274 <!-- -->rbc { display: ruby-base-container; }
1275 <!-- -->rtc { display: ruby-text-container; }</pre>
1277 <p>Additional rules for UAs supporting the relevant features of [[CSS3-TEXT-DECOR]] and [[CSS3-FONTS]]:
1278 <pre>rt { font-variant-east-asian: ruby; text-emphasis: none; }</pre>
1280 <p class="note">Authors should not use the above rules;
1281 a UA that supports ruby layout should provide these by default.
1283 <h3 id="default-inline" class="no-num">
1284 <span class="secno">A.2</span> Inlining Ruby Annotations</h3>
1286 <p>The following represents a sample style sheet
1287 for rendering HTML and XHTML ruby markup as inline annotations:
1289 <pre>ruby, rb, rt, rbc, rtc, rp {
1290 <!-- --> display: inline; white-space: inherit;
1291 <!-- --> font-variant-east-asian: inherit; text-emphasis: inherit; }</pre>
1293 <h3 id="default-parens" class="no-num">
1294 <span class="secno">A.3</span> Generating Parentheses</h3>
1296 <p>Unfortunately, because Selectors cannot match against text nodes,
1297 it's not possible with CSS to express rules that will automatically and correctly
1298 add parentheses to unparenthesized ruby annotations in HTML.
1299 (This is because HTML ruby allows implying the <i>ruby base</i> from raw text, without a corresponding element.)
1300 However, these rules will handle cases where either <code><rb></code>
1301 or <code><rtc></code> is used rigorously.
1303 <pre>
1304 <!-- -->/* Parens around <rtc> */
1305 <!-- -->rtc::before { content: "("; }
1306 <!-- -->rtc::after { content: ")"; }
1308 <!-- -->/* Parens before first <rt> not inside <rtc> */
1309 <!-- -->rb + rt::before,
1310 <!-- -->rtc + rt::before { content: "("; }
1312 <!-- -->/* Parens after <rt> not inside <rtc> */
1313 <!-- -->rb ~ rt:last-child::after,
1314 <!-- -->rt + rb::before { content: ")"; }
1315 <!-- -->rt + rtc::before { content: ")("; }</pre>
1317 <h2 id="glossary">
1318 Glossary</h2>
1319 <dl>
1320 <dt><a id="g-bopomofo"><strong><span
1321 lang="zh">Bopomofo</span></strong></a></dt>
1322 <dd>37 characters and 4 tone markings used as phonetics in Chinese,
1323 especially standard Mandarin.</dd>
1324 <dt><a id="g-hanja"><strong><span
1325 lang="ko">Hanja</span></strong></a></dt>
1326 <dd>Subset of the Korean writing system that utilizes ideographic
1327 characters borrowed or adapted from the Chinese writing system. Also see
1328 <a href="#g-kanji"><span lang="ja">Kanji</span></a>.</dd>
1329 <dt><a id="g-hiragana"><strong><span
1330 lang="ja">Hiragana</span></strong></a></dt>
1331 <dd>Japanese syllabic script, or character of that script. Rounded and
1332 cursive in appearance. Subset of the Japanese writing system, used together
1333 with kanji and katakana. In recent times, mostly used to write Japanese
1334 words when kanji are not available or appropriate, and word endings and
1335 particles. Also see <a
1336 href="#g-katakana"><span lang="ja">Katakana</span></a>.</dd>
1337 <dt><a id="g-ideogram"><strong>Ideograph</strong></a></dt>
1338 <dd>A character that is used to represent an idea, word, or word component,
1339 in contrast to a character from an alphabetic or syllabic script. The most
1340 well-known ideographic script is used (with some variation) in East Asia
1341 (China, Japan, Korea,...).</dd>
1342 <dt><a id="g-kana"><strong><span lang="ja">Kana</span></strong></a></dt>
1343 <dd>Collective term for hiragana and katakana.</dd>
1344 <dt><a id="g-kanji"><strong>Kanji</strong></a></dt>
1345 <dd>Japanese term for ideographs; ideographs used in Japanese. Subset of the
1346 Japanese writing system, used together with hiragana and katakana. Also see <a
1347 href="#g-hanja"><span lang="ko">Hanja</span></a>.</dd>
1348 <dt><a id="g-katakana"><strong><span
1349 lang="ja">Katakana</span></strong></a></dt>
1350 <dd>Japanese syllabic script, or character of that script. Angular in
1351 appearance. Subset of the Japanese writing system, used together with
1352 kanji and hiragana. In recent times, mainly used to write foreign words. Also see <a
1353 href="#g-hiragana"><span lang="ja">Hiragana</span></a>.</dd>
1354 <dt><a id="g-monoruby" name="g-monoruby"><strong>Mono-ruby</strong></a></dt>
1355 <dd>In Japanese typography: Ruby associated with a single character of
1356 the base text.</dd>
1357 <dt><a id="g-ruby"><strong>Ruby</strong></a></dt>
1358 <dd>A run of text that appears in the vicinity of another run of text and
1359 serves as an annotation or a pronunciation guide for that text.</dd>
1360 </dl>
1362 <h2 id="conformance">
1363 Conformance</h2>
1365 <h3 id="conventions">
1366 Document conventions</h3>
1368 <p>Conformance requirements are expressed with a combination of
1369 descriptive assertions and RFC 2119 terminology. The key words “MUST”,
1370 “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
1371 “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
1372 document are to be interpreted as described in RFC 2119.
1373 However, for readability, these words do not appear in all uppercase
1374 letters in this specification.
1376 <p>All of the text of this specification is normative except sections
1377 explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
1379 <p>Examples in this specification are introduced with the words “for example”
1380 or are set apart from the normative text with <code>class="example"</code>,
1381 like this:
1383 <div class="example">
1384 <p>This is an example of an informative example.</p>
1385 </div>
1387 <p>Informative notes begin with the word “Note” and are set apart from the
1388 normative text with <code>class="note"</code>, like this:
1390 <p class="note">Note, this is an informative note.</p>
1392 <h3 id="conformance-classes">
1393 Conformance classes</h3>
1395 <p>Conformance to CSS Ruby Module
1396 is defined for three conformance classes:
1397 <dl>
1398 <dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
1399 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
1400 style sheet</a>.
1401 <dt><dfn>renderer</dfn></dt>
1402 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1403 that interprets the semantics of a style sheet and renders
1404 documents that use them.
1405 <dt><dfn id="authoring-tool">authoring tool</dfn></dt>
1406 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1407 that writes a style sheet.
1408 </dl>
1410 <p>A style sheet is conformant to CSS Ruby Module
1411 if all of its statements that use syntax defined in this module are valid
1412 according to the generic CSS grammar and the individual grammars of each
1413 feature defined in this module.
1415 <p>A renderer is conformant to CSS Ruby Module
1416 if, in addition to interpreting the style sheet as defined by the
1417 appropriate specifications, it supports all the features defined
1418 by CSS Ruby Module by parsing them correctly
1419 and rendering the document accordingly. However, the inability of a
1420 UA to correctly render a document due to limitations of the device
1421 does not make the UA non-conformant. (For example, a UA is not
1422 required to render color on a monochrome monitor.)
1424 <p>An authoring tool is conformant to CSS Ruby Module
1425 if it writes style sheets that are syntactically correct according to the
1426 generic CSS grammar and the individual grammars of each feature in
1427 this module, and meet all other conformance requirements of style sheets
1428 as described in this module.
1430 <h3 id="partial">
1431 Partial implementations</h3>
1433 <p>So that authors can exploit the forward-compatible parsing rules to
1434 assign fallback values, CSS renderers <strong>must</strong>
1435 treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
1436 as appropriate</a>) any at-rules, properties, property values, keywords,
1437 and other syntactic constructs for which they have no usable level of
1438 support. In particular, user agents <strong>must not</strong> selectively
1439 ignore unsupported component values and honor supported values in a single
1440 multi-value property declaration: if any value is considered invalid
1441 (as unsupported values must be), CSS requires that the entire declaration
1442 be ignored.</p>
1444 <h3 id="experimental">
1445 Experimental implementations</h3>
1447 <p>To avoid clashes with future CSS features, the CSS2.1 specification
1448 reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
1449 syntax</a> for proprietary and experimental extensions to CSS.
1451 <p>Prior to a specification reaching the Candidate Recommendation stage
1452 in the W3C process, all implementations of a CSS feature are considered
1453 experimental. The CSS Working Group recommends that implementations
1454 use a vendor-prefixed syntax for such features, including those in
1455 W3C Working Drafts. This avoids incompatibilities with future changes
1456 in the draft.
1457 </p>
1459 <h3 id="testing">
1460 Non-experimental implementations</h3>
1462 <p>Once a specification reaches the Candidate Recommendation stage,
1463 non-experimental implementations are possible, and implementors should
1464 release an unprefixed implementation of any CR-level feature they
1465 can demonstrate to be correctly implemented according to spec.
1467 <p>To establish and maintain the interoperability of CSS across
1468 implementations, the CSS Working Group requests that non-experimental
1469 CSS renderers submit an implementation report (and, if necessary, the
1470 testcases used for that implementation report) to the W3C before
1471 releasing an unprefixed implementation of any CSS features. Testcases
1472 submitted to W3C are subject to review and correction by the CSS
1473 Working Group.
1475 <p>Further information on submitting testcases and implementation reports
1476 can be found from on the CSS Working Group's website at
1477 <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
1478 Questions should be directed to the
1479 <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
1480 mailing list.
1482 <h2 class=no-num id="acknowledgments">
1483 Acknowledgments</h2>
1485 <p>This specification would not have been possible without the help from:</p>
1487 <p>Stephen Deach, Martin Dürst, Hideki Hiura(<span lang="ja">樋浦 秀樹</span>), Masayasu Ishikawa(<span lang="ja">石川
1488 雅康</span>), Chris
1489 Pratley, Takao Suzuki(<span lang="ja">鈴木 孝雄</span>), Frank Yung-Fong Tang, Chris Thrasher, Masafumi Yabe<span lang="ja">家辺
1490 勝文</span>), Steve Zilles.</p>
1492 <h2 class="no-num" id="changes">
1493 Changes</h2>
1495 <p>The following major changes have been made since the previous Working Draft:
1496 <dl>
1497 <dt>Remove 'ruby-span' and mentions of <code>rbspan</code>.
1498 <dd>
1499 Explicit spanning is not used in HTML ruby in favor of implicit spanning.
1500 This can't handle some pathological double-sided spanning cases,
1501 but there seems to be no requirement for these at the moment.
1502 (For implementations that support full complex XHTML Ruby,
1503 they can imply spanning from the markup the same magic way
1504 that we handle cell spanning from tables. It doesn't seem
1505 necessary to include controls this in Level 1.)
1507 <dt>Defer 'ruby-overhang' and ''ruby-align: line-end'' to Level 2.
1508 <dd>
1509 It's somewhat complicated, advanced feature.
1510 Proposal is to make this behavior UA-defined
1511 and provide some examples of acceptable options.
1513 <dt>Close issue requesting 'display: rp': use ''display: none''.
1514 <dd>
1515 The i18nwg added an issue requesting a display value for <rp> elements.
1516 They're supposed to be hidden when &tl;ruby> is displayed as ruby.
1517 But this is easily accomplished already with ''display: none''.
1519 <dt>Change 'ruby-position' values to match 'text-emphasis-position'.
1520 <dd>
1521 Other than ''inter-character'', which we need to keep,
1522 it makes more sense to align ruby positions with 'text-emphasis-position',
1523 which can correctly handle various combinations of horizontal/vertical preferences.
1525 <dt>Remove unused values of 'ruby-align'.
1526 <dd>
1527 'left', 'right', and 'end' are not needed.
1529 <dt>Added 'ruby-merge' property to control jukugo rendering.
1530 <dd>
1531 This is a stylistic effect, not a structural one;
1532 the previous model assumed that it was structural and suggested handling it by changing markup. :(
1534 <dt>Remove ''inline'' from 'ruby-position'.
1535 <dd>
1536 This is do-able via ''display: inline'' on all the ruby-related elements,
1537 see <a href="#default-inline">Appendix A</a>
1539 <dt>Added <a href="#default-style">Default Style</a> rules
1540 <dd>
1541 As requested by i18nwg.
1543 <dt>Wrote anonymous box generation rules
1544 <dd>
1545 And defined pairing of bases and annotations.
1546 Should now handle all the crazy proposed permutations of HTML ruby markup.
1547 </dl>
1549 <h2 class=no-num id="references">
1550 References</h2>
1552 <h3 class="no-num" id="normative-references">
1553 Normative references</h3>
1554 <!--normative-->
1556 <h3 class="no-num" id="other-references">
1557 Other references</h3>
1558 <!--informative-->
1560 <h2 class="no-num" id="index">
1561 Index</h2>
1562 <!--index-->
1564 <h2 class="no-num" id="property-index">
1565 Property index</h2>
1566 <!-- properties -->
1568 </body>
1569 </html>
1570 <!-- Keep this comment at the end of the file
1571 Local variables:
1572 mode: sgml
1573 sgml-declaration:"~/SGML/HTML4.decl"
1574 sgml-default-doctype-name:"html"
1575 sgml-minimize-attributes:t
1576 sgml-nofill-elements:("pre" "style" "br")
1577 sgml-live-element-indicator:t
1578 sgml-omittag:nil
1579 sgml-shorttag:nil
1580 sgml-namecase-general:t
1581 sgml-general-insert-case:lower
1582 sgml-always-quote-attributes:t
1583 sgml-indent-step:nil
1584 sgml-indent-data:t
1585 sgml-parent-document:nil
1586 sgml-exposed-tags:nil
1587 sgml-local-catalogs:nil
1588 sgml-local-ecat-files:nil
1589 End:
1590 -->