Tue, 25 Jun 2013 18:53:52 -0700
[css-cascade] minor editorial tweaks from f2f commentary
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 bases</i> are 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>. [[!CSS3-TEXT]]
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="line-breaking">
489 Ruby box and line breaking</h3>
491 <p>When there is not enough space for an entire <i>ruby container</i> to fit on the line,
492 the ruby may be broken wherever all levels allow a break.
493 In typical cases, line breaks are forbidden within each <i>ruby base</i> and <i>ruby annotation</i>,
494 so the <i>ruby container</i> can only break between adjacent <i>ruby bases</i>,
495 and only if no <i>ruby annotations</i> span those <i>ruby bases</i>.
496 Whenever ruby breaks across lines, <i>ruby annotations</i>
497 <em>must</i> stay with their respective bases.
499 <div class="figure">
500 <p><img src="images/r-break-a.gif"
501 alt="Diagram showing the line breaking opportunity in a complex ruby">
502 <p class="caption">Ruby line breaking opportunity
503 </div>
505 <p>Whether ruby can break between two adjacent <i>ruby bases</i>
506 is controlled by normal line-breaking rules for the affected text,
507 exactly as if the <i>ruby bases</i> were regular <i>inline</i> boxes.
509 <div class="example">
510 <p>For example, if two adjacent ruby bases are “蝴” and “蝶”,
511 the line may break between them,
512 because lines are normally allowed to break between two Han characters.
513 However, if 'word-break' is ''keep-all'', that line break is forbidden.
514 </div>
516 <p>Inter-base white space is significant for evaluating line break opportunities between <i>ruby bases</i>.
517 As with white space between inlines, it collapses when the line breaks there.
519 <div class="example">
520 <p>For example, given the following markup:
521 <pre><ruby><rb>one</rb> <rb>two</rb> <rt>1</rt> <rt>2</rt></ruby></pre>
522 <p>Due to the space, the line may break between “one” and “two“.
523 If the line breaks there, that space disappears,
524 in accordance with standard CSS white space processing rules. [[CSS3-TEXT]]
525 </div>
527 <p>The line <em>must not</em> break between a <i>ruby base</i> and its annotations.
529 <div class="figure">
530 <img src="images/r-break-b.gif"
531 alt='Diagram showing the line breaking opportunity in a "Bopomofo" ruby'>
532 <p class="caption">''inter-character'' ruby line breaking opportunity
533 </div>
535 <h3 id="line-height">
536 Ruby box and line stacking</h3>
538 <p>The 'line-height' property controls spacing between lines in CSS.
539 When inline content on line is shorter than the 'line-height',
540 half-leading is added on either side of the content,
541 as specificed in <a href="http://www.w3.org/TR/CSS21/visudet.html#line-height">CSS2.1§10.8</a>. [[!CSS21]]
543 <p>In order to ensure consistent spacing of lines,
544 documents with ruby typically ensure that the 'line-height' is large enough
545 to accommodate ruby between lines of text.
546 Therefore, ordinarily, <i>ruby annotation containers</i> and <i>ruby annotation boxes</i>
547 do not contribute to the measured height of a line's inline contents;
548 any alignment (see 'vertical-align') and line-height calculations
549 are performed using only the <i>ruby base container</i>,
550 exactly as if it were a normal inline.
552 <p>However, if the 'line-height' specified on the <i>ruby container</i>
553 is less than the distance between
554 the top of the top <i>ruby annotation container</i>
555 and the bottom of the bottom <i>ruby annotation container</i>,
556 then additional leading is added
557 on the appropriate side of the <i>ruby base container</i>
558 such that if a block consisted of three lines
559 each containing ruby identical to this,
560 none of the <i>ruby containers</i> would overlap.
562 <p class="note">Note that this does not ensure that the <i>ruby annotations</i> remain within the line box.
563 It merely ensures that <em>if all lines had equal spacing</em>
564 and equivalent amounts and positioning of <i>ruby annotations</i>,
565 there would be enough room to avoid overlap.
567 <p>Authors should ensure appropriate 'line-height' and 'padding' to accommodate ruby,
568 and be particularly careful at the beginning or end of a block
569 and when a line contains inline-level content
570 (such as images, inline blocks, or elements shifted with 'vertical-align')
571 taller than the paragraph's default font size.
573 <div class="figure">
574 <p><img src="images/rlh-a.gif"
575 alt="The content of each line sits in the middle of its line height;
576 the additional space on each side is called half-leading.
577 Ruby fits between lines if it is smaller than twice the half-leading,
578 but this means that it occupies space belonging to the half-leading of the previous line.">
579 <p class="caption">Ruby annotations will often overflow the line;
580 authors should ensure content over/under a ruby-annotated line
581 is adequately spaced to leave room for the ruby.
582 </div>
584 <p class="note">More control over how ruby affects alignment and line layout
585 will be part of the CSS Line Layout Module Level 3.
586 Note, it is currently in the process of being rewritten;
587 the current drafts should not be relied upon.
589 <h2 id="ruby-props">
590 Ruby Properties</h2>
592 <p>The following properties are introduced to control ruby positioning and alignment.
594 <h3 id="rubypos">
595 Ruby positioning: the 'ruby-position' property</h3>
597 <table class="propdef">
598 <tr>
599 <th>Name:
600 <td><dfn>ruby-position</dfn>
601 <tr>
602 <th><a href="#values">Value</a>:
603 <td>[ over | under | inter-character ] && [ right | left ]
604 <tr>
605 <th>Initial:
606 <td>over right
607 <tr>
608 <th>Applies to:
609 <td>ruby annotation containers
610 <tr>
611 <th>Inherited:
612 <td>yes
613 <tr>
614 <th>Percentages:
615 <td>N/A
616 <tr>
617 <th>Media:
618 <td>visual
619 <tr>
620 <th>Computed value:
621 <td>specified value
622 <tr>
623 <th>Animatable:
624 <td>no
625 <tr>
626 <th>Canonical order:
627 <td><abbr title="follows order of property value definition">per grammar</abbr>
628 </table>
630 <p>This property controls position of the ruby text with respect to its base.
631 Values have the following meanings:
633 <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>
634 <dl>
635 <dt><dfn title="ruby-position:over">''over''</dfn>
636 <dd>The ruby text appears <i>over</i> the base in horizontal text.
638 <div class="figure">
639 <p><img src="images/shinkansen-top.gif"
640 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing above the base">
641 <p class="caption">Ruby over Japanese base text in horizontal layout
642 </div>
643 </dd>
645 <dt><dfn title="ruby-position:right">''right''</dfn>
646 <dd>The ruby text appears on the right side of the base in vertical text.
647 <div class="figure">
648 <p><img src="images/shinkansen-right.gif" width="33"
649 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the right of the base">
650 <p class="caption">Ruby to the right of Japanese base text in vertical layout
651 </div>
652 </dd>
654 <dt><dfn title="ruby-position:under">''under''</dfn>
655 <dd>The ruby text appears under the base in horizontal text.
656 This is a relatively rare setting used in ideographic East Asian writing systems,
657 most easily found in educational text.
659 <div class="figure">
660 <p><img src="images/shinkansen-bottom.gif"
661 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing below the base">
662 <p class="caption">Ruby under Japanese base text in horizontal layout
663 </div>
664 </dd>
666 <dt><dfn title="ruby-position:left">''left''</dfn>
667 <dd>The ruby text appears on the left side of the base in vertical text.
669 <div class="figure">
670 <p><img src="images/shinkansen-left.gif"
671 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the left of the base">
672 <p class="caption">Ruby to the left of Japanese base text in vertical layout
673 </div>
674 </dd>
676 <dt><dfn title="ruby-position:inter-character">''inter-character''</dfn></dt>
677 <dd>
678 <p>The ruby text appears on the right of the base in horizontal text.
679 This value forces the 'writing-mode' of the <i>ruby annotation</i> to be vertical.
681 <p>This value is provided for the special case of traditional Chinese
682 as used especially in Taiwan:
683 ruby (made of <a href="#g-bopomofo">bopomofo</a> glyphs) in that context
684 appears vertically along the right side of the base glyph,
685 even when the layout of the base characters is horizontal:
687 <div class="figure">
688 <p><img src="images/bopomofo.gif"
689 alt="Example of Taiwanese-style ruby">
690 <p class="caption">“Bopomofo” ruby in traditional Chinese
691 (ruby text shown in blue for clarity) in horizontal layout
692 </div>
693 <p class="note">
694 Note that the user agent is responsible for ensuring the correct relative alignment and positioning of the glyphs,
695 including those corresponding to the tone marks, when displaying.
696 Tone marks are spacing characters that occur (in memory) at the end of the ruby text for each base character.
697 They are usually displayed in a separate column to the right of the bopomofo characters,
698 and the height of the tone mark depends on the number of characters in the syllable.
699 One tone mark, however, is placed above the bopomofo, not to the right of it.
700 <!-- See Taiwanese requirements doc for EPUB at http://epub-revision.googlecode.com/files/EGLS_TW_eng.ppt -->
701 </dd>
702 </dl>
704 <p>If multiple <i>ruby annotation containers</i> have the same 'ruby-position',
705 they stack along the block axis,
706 with lower levels of annotation closer to the base text.
708 <h3 id="collapsed-ruby">
709 Collapsed Ruby Annotations: the 'ruby-merge' property</h3>
711 <table class="propdef">
712 <tr>
713 <th>Name:
714 <td><dfn>ruby-merge</dfn>
715 <tr>
716 <th><a href="#values">Value</a>:
717 <td>separate | collapse | auto
718 <tr>
719 <th>Initial:
720 <td>separate
721 <tr>
722 <th>Applies to:
723 <td>ruby annotation containers
724 <tr>
725 <th>Inherited:
726 <td>yes
727 <tr>
728 <th>Percentages:
729 <td>N/A
730 <tr>
731 <th>Media:
732 <td>visual
733 <tr>
734 <th>Computed value:
735 <td>specified value
736 <tr>
737 <th>Animatable:
738 <td>no
739 <tr>
740 <th>Canonical order:
741 <td><abbr title="follows order of property value definition">per grammar</abbr>
742 </table>
744 <p>
745 This property controls how ruby annotation boxes should be rendered
746 when there are more than one in a ruby container box.
748 <p>Possible values:</p>
749 <dl>
750 <dt><dfn title="ruby-merge:separate">''separate''</dfn>
751 <dd>
752 <p>
753 Each ruby annotation box is rendered in the same column(s) as its corresponding base box(es).
754 This style is called “mono ruby” in [[JLREQ]].
756 <div class="example">
757 <p>For example, the following two markups render the same:
758 <pre><ruby>無<rt>む</ruby><ruby>常<rt>じょう</ruby></pre>
759 <p>and:
760 <pre><ruby style="ruby-merge:separate"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
761 </div>
762 </dd>
764 <dt><dfn title="ruby-merge:collapse">''collapse''</dfn>
765 <dd>
766 <p>
767 All <i>ruby annotation boxes</i> within the same <i>ruby segment</i> on the same line are concatenated,
768 and laid out as if their contents belonged to a single <i>ruby annotation box</i>
769 spanning all their associated <i>ruby base boxes.
770 This style renders similar to “group ruby” in [[JLREQ]],
771 except that <i>ruby annotations</i> are kept together with their respective <i>ruby bases</i> when breaking lines.
772 </p>
774 <div class="example">
775 <p>The following two markups render the same both characters fit on one line:
776 <pre><ruby>無常<rt>むじょう</ruby></pre>
777 <p>and:
778 <pre><ruby style="ruby-merge:collapse"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
779 <p>However, the second one renders the same as ''ruby-position: separate''
780 when the two bases are split across lines.
781 </div>
782 </dd>
784 <dt><dfn title="ruby-merge:auto">''auto''</dfn></dt>
785 <dd>
786 <p>
787 The user agent may use any algorithm to determine how each ruby annotation box
788 is rendered to its corresponding base box.
789 <div class="example">
790 <p>
791 One possible algorithm is described as Jukugo-ruby in [[JLREQ]].
792 <p>
793 Another, more simplified algorithm of Jukugo-ruby is
794 to render as Mono-ruby if all ruby annotation boxes fit within
795 advances of their corresponding base boxes,
796 and render as Group-ruby otherwise.
797 </p>
798 </div>
799 </dd>
800 </dl>
802 <h3 id="rubyalign">
803 Ruby Text Distribution: the 'ruby-align' property</h3>
805 <table class="propdef">
806 <tr>
807 <th>Name:
808 <td><dfn>ruby-align</dfn>
809 <tr>
810 <th><a href="#values">Value</a>:
811 <td>auto | start | center |
812 distribute-letter | distribute-space
813 <tr>
814 <th>Initial:
815 <td>auto
816 <tr>
817 <th>Applies to:
818 <td>ruby bases, ruby annotations, ruby base containers, ruby annotation containers
819 <tr>
820 <th>Inherited:
821 <td>yes
822 <tr>
823 <th>Percentages:
824 <td>N/A
825 <tr>
826 <th>Media:
827 <td>visual
828 <tr>
829 <th>Computed value:
830 <td>specified value (except for initial and inherit)
831 </table>
833 <p>This property specifies how text is distributed within the various ruby boxes
834 when their text contents exactly fill their respective boxes.
836 <p>Values have the following meanings:
837 <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>
838 <dl>
839 <dt><dfn title="ruby-align:auto">''auto''</dfn></dt>
840 <dd>
841 <p>The user agent determines how the ruby contents are aligned.
842 This is the initial value.
843 The behavior recommended by [[JLREQ]] is for wide-cell ruby to be aligned in the 'distribute-space' mode:
844 <div class="figure">
845 <p><img width="145" height="91"
846 alt="Diagram of glyph layout in auto aligned ruby when ruby text is shorter than base"
847 src="images/ra-ds.gif" /><img width="145" height="91"
848 alt="Diagram of glyph layout in auto aligned ruby when ruby text is longer than base"
849 src="images/ra-ds-rb.gif" /></p>
850 <p><b>Figure 4.2.1</b>: Wide-cell text in 'auto' ruby alignment is
851 'distribute-space' justified</p>
852 </div>
854 <p>The recommended behavior for narrow-cell glyph ruby is to be
855 aligned in the 'center' mode.</p>
856 <div class="figure">
857 <p><img
858 alt="Diagram of glyph layout in auto aligned ruby when halfwidth ruby text is shorter than base"
859 width="145" height="91"
860 src="images/ra-c-h.gif" /><img
861 alt="Diagram of character layout in auto aligned ruby when ruby text is longer than narrow-width base"
862 width="145" height="91"
863 src="images/ra-c-rb-h.gif" /></p>
864 <p><b>Figure 4.2.2</b>: Narrow-width ruby text in 'auto' ruby alignment
865 is centered</p>
866 </div>
867 </dd>
869 <dt><dfn title="ruby-align:start">''start''</dfn></dt>
870 <dd>The ruby annotation content is aligned with the start edge of the base.
871 <div class="figure">
872 <p><img
873 alt="Diagram of glyph layout in left aligned ruby when ruby text is shorter than base"
874 width="145" height="91" src="images/ra-l.gif" /><img
875 width="145" height="91"
876 alt="Diagram of glyph layout in left aligned ruby when ruby text is longer than base"
877 src="images/ra-l-rb.gif" /></p>
878 <p><b>Figure 4.2.3</b>: Start ruby alignment</p>
879 </div>
880 </dd>
882 <dt><dfn title="ruby-align:center">''center''</dfn></dt>
883 <dd>The ruby text content is centered within the width of the base. If the
884 length of the base is smaller than the length of the ruby text, then the
885 base is centered within the width of the ruby text.
887 <div class="figure">
888 <p><img width="145" height="91"
889 alt="Diagram of glyph layout in center aligned ruby when ruby text is shorter than base"
890 src="images/ra-c.gif" /><img width="145" height="91"
891 alt="Diagram of glyph layout in center aligned ruby when ruby text is longer than base"
892 src="images/ra-c-rb.gif" /></p>
893 <p><b>Figure 4.2.4</b>: Center ruby alignment</p>
894 </div>
895 </dd>
897 <!--
898 <dt><strong>right</strong></dt>
899 <dd>The ruby text content is aligned with the end edge of the base.
900 <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>
901 <div class="figure">
902 <p><img class="example" width="145" height="91"
903 alt="Diagram of glyph layout in right aligned ruby when ruby text is shorter than base"
904 src="images/ra-r.gif" /><img class="example" width="145" height="91"
905 alt="Diagram of glyph layout in right aligned ruby when ruby text is longer than base"
906 src="images/ra-r-rb.gif" /></p>
907 <p><b>Figure 4.2.5</b>: End ruby alignment</p>
908 </div>
909 </dd>
910 -->
912 <dt><dfn title="ruby-align:distribute-letter">''distribute-letter''</dfn></dt>
913 <dd>If the width of the ruby text is smaller than that of the base, then
914 the ruby text contents are evenly distributed across the width of the
915 base, with the first and last ruby text glyphs lining up with the
916 corresponding first and last base glyphs. If the width of the ruby text
917 is at least the width of the base, then the letters of the base are
918 evenly distributed across the width of the ruby text.
920 <div class="figure">
921 <p><img width="145" height="91"
922 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is shorter than base"
923 src="images/ra-dl.gif" /><img width="145" height="91"
924 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is longer than base"
925 src="images/ra-dl-rb.gif" /></p>
926 <p><b>Figure 4.2.6</b>: Distribute-letter ruby alignment</p>
927 </div>
928 </dd>
930 <dt><dfn title="ruby-align:distribute-space">''distribute-space''</dfn></dt>
931 <dd>If the width of the ruby text is smaller than that of the base, then
932 the ruby text contents are evenly distributed across the width of the
933 base, with a certain amount of white space preceding the first and
934 following the last character in the ruby text. That amount of white
935 space is normally equal to half the amount of inter-character space of
936 the ruby text. If the width of the ruby text is at least the width of
937 the base, then the same type of space distribution applies to the base.
938 In other words, if the base is shorter than the ruby text, the base is
939 distribute-space aligned. This type of alignment
940 is described by [[JLREQ]].
942 <div class="figure">
943 <p><img width="145" height="91"
944 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is shorter than base"
945 src="images/ra-ds.gif" /><img width="145" height="91"
946 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is longer than base"
947 src="images/ra-ds-rb.gif" /></p>
948 <p><b>Figure 4.2.7</b>: Distribute-space ruby alignment</p>
949 </div>
950 </dd>
952 <!--
953 <dt><strong>line-edge</strong></dt>
954 <dd>If the ruby text is not adjacent to a line edge, it is aligned as in
955 'auto'. If it is adjacent to a line edge, then it is still aligned as in
956 auto, but the side of the ruby text that touches the end of the line is
957 lined up with the corresponding edge of the base. This type of alignment
958 is described by [[JLREQ]]. This type of alignment is
959 relevant only to the scenario where the ruby text is longer than the
960 ruby base. In the other scenarios, this is just 'auto'.
961 <div class="figure">
962 <p><img class="example" width="146" height="109"
963 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base"
964 src="images/ra-le-l.gif" /><img class="example" width="146"
965 height="110"
966 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base"
967 src="images/ra-le-r.gif" /></p>
968 <p><b>Figure 4.2.8</b>: Line edge ruby alignment</p>
969 </div>
970 </dd>
971 -->
972 </dl>
974 <p>For a complex ruby with spanning elements, one additional consideration is
975 required. If the spanning element spans multiple 'rows' (other rbc or rtc
976 elements), and the ruby alignment requires space distribution among the
977 'spanned' elements, a ratio must be determined among the 'columns' of spanned
978 elements. This ratio is computed by taking into consideration the widest
979 element within each column.</p>
981 <h2 id="edge-effects">
982 Edge Effects</h2>
984 <h3 id="ruby-overhang">
985 Overhanging Ruby</h3>
987 <p>
988 When <i>ruby annotation box</i> is longer than its corresponding <i>ruby base box</i>,
989 the <i>ruby annotation box</i> may partially overhang adjacent boxes.
990 </p>
991 <p>
992 This level of the specification does not define
993 how much the overhang may be allowed, and under what conditions.
994 </p>
996 <p>If the ruby text is not allowed to overhang,
997 then the ruby behaves like a traditional inline box,
998 i.e. only its own contents are rendered within its boundaries
999 and adjacent elements do not cross the box boundary:
1001 <div class="figure">
1002 <p><img src="images/ro-n.gif"
1003 alt="Diagram showing the ruby boxes interacting with adjacent text">
1004 <p class="caption">Simple ruby whose text is not allowed to overhang adjacent text
1005 </div>
1007 <p>However, if <i>ruby annotation</i> content is allowed to overhang adjacent elements
1008 and it happens to be wider than its base,
1009 then the adjacent content is partially rendered within the area of the <i>ruby container box</i>,
1010 while the <i>ruby annotation</i> may partially overlap the upper blank parts of the adjacent content:
1012 <div class="figure">
1013 <p><img src="images/ro-a.gif"
1014 alt="Diagram showing the ruby boxes interacting with adjacent text">
1015 <p class="caption">Simple ruby whose text is allowed to overhang adjacent text
1016 </div>
1018 <p>The <i>ruby annotations</i> related to a <i>ruby base</i>
1019 must never overhang another <i>ruby base</i>.
1021 <p>The alignment of the contents of the base or the ruby text
1022 is not affected by overhanging behavior.
1023 The alignment is achieved the same way regardless of the overhang behavior setting
1024 and it is computed before the space available for overlap is determined.
1025 It is controlled by the 'ruby-align' property.
1027 <p>This entire logic applies the same way in vertical ideographic layout,
1028 only the dimension in which it works in such a layout is vertical,
1029 instead of horizontal.
1031 <div class="example">
1032 <p>
1033 The user agent may use [[JIS4051]] recommendation of
1034 using one ruby text character length as the maximum overhang length.
1035 Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].
1036 </p>
1037 </div>
1039 <h3 id="line-edge">
1040 Line-edge Alignment</h3>
1042 <p>
1043 When a <i>ruby annotation box</i> that is longer than its <i>ruby base</i>
1044 is at the start or end edge of a line,
1045 the user agent <em>may</em> force the side of the <i>ruby annotation</i> that touches the edge of the line
1046 to align to the corresponding edge of the base.
1047 This type of alignment is described by [[JLREQ]].
1048 </p>
1049 <p>
1050 This level of the specification does not provide a mechanism to control this behavior.
1051 </p>
1052 <div class="figure">
1053 <p><img src="images/ra-le-l.gif"
1054 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base">
1055 <img src="images/ra-le-r.gif"
1056 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base">
1057 <p class="caption">Line-edge alignment
1058 </div>
1060 <!--
1061 <h3 id="rubyover">
1062 Ruby overhanging: the 'ruby-overhang' property</h3>
1064 <table class="propdef">
1065 <tr>
1066 <th>Name:
1067 <td><dfn>ruby-overhang</dfn>
1068 <tr>
1069 <th>Value:
1070 <td>auto | start | end | none
1071 <tr>
1072 <th>Initial:
1073 <td>none
1074 <tr>
1075 <th>Applies to:
1076 <td>the parent of elements with display: ruby-text
1077 <tr>
1078 <th>Inherited:
1079 <td>yes
1080 <tr>
1081 <th>Percentages:
1082 <td>N/A
1083 <tr>
1084 <th>Media:
1085 <td>visual
1086 <tr>
1087 <th>Computed value:
1088 <td>specified value (except for initial and inherit)
1089 </table>
1091 <p>This property determines whether, and on which side, ruby text is allowed
1092 to partially overhang any adjacent text in addition to its own base, when the
1093 ruby text is wider than the ruby base. Note that ruby text is never allowed to
1094 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
1095 a maximum amount by which ruby text may overhang adjacent text. The user agent may use
1096 the [[JIS4051]] recommendation of using one ruby text character
1097 length as the maximum overhang length. Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].</p>
1099 <p>Possible values:</p>
1100 <dl>
1101 <dt><strong>auto</strong></dt>
1102 <dd>The ruby text can overhang text adjacent to the base on either side. [[JLREQ]] and [[JIS4051]] specify the categories of characters that
1103 ruby text can overhang. The user agent is free to follow those recommendations or specify its own classes of
1104 characters to overhang. This is the initial value.
1105 <div class="figure">
1106 <p><img class="example" width="177" height="91"
1107 alt="Diagram of glyph layout in overhanging ruby" src="images/ro-a.gif" /></p>
1108 <p><b>Figure 4.3.1</b>: Ruby overhanging adjacent text</p>
1109 </div>
1110 </dd>
1111 <dt><strong>start</strong></dt>
1112 <dd>The ruby text can only overhang the text that precedes it. That means, for
1113 example, that ruby cannot overhang text that is to the right of it in
1114 horizontal LTR layout, and it cannot overhang text that is below it in
1115 vertical-ideographic layout.
1116 <div class="figure">
1117 <p><img class="example" width="199" height="91"
1118 alt="Diagram of glyph layout when ruby overhangs the preceding glyphs only"
1119 src="images/ro-s.gif" /></p>
1120 <p><b>Figure 4.3.2</b>: Ruby overhanging preceding text only</p>
1121 </div>
1122 </dd>
1123 <dt><strong>end</strong></dt>
1124 <dd>The ruby text can only overhang the text that follows it. That means, for
1125 example, that ruby cannot overhang text that is to the left of it in
1126 horizontal LTR layout, and it cannot overhang text that is above it in
1127 vertical-ideographic layout.
1128 <div class="figure">
1129 <p><img class="example" width="198" height="91"
1130 alt="Diagram of glyph layout when ruby overhangs the following characters only"
1131 src="images/ro-e.gif" /></p>
1132 <p><b>Figure 4.3.3</b>: Ruby overhanging following text only</p>
1133 </div>
1134 </dd>
1135 <dt><strong>none</strong></dt>
1136 <dd>The ruby text cannot overhang any text adjacent to its base, only its
1137 own base.
1139 <div class="figure">
1140 <p><img class="example" width="220" height="91"
1141 alt="Diagram of glyph layout in non-overhanging ruby"
1142 src="images/ro-n.gif" /></p>
1143 <p><b>Figure 4.3.4</b>: Ruby not allowed to overhang adjacent text</p>
1144 </div>
1145 </dd>
1146 </dl>
1148 <h3 id="rubyspan">
1149 Ruby annotation spanning: the 'ruby-span' property</h3>
1151 <table class="propdef">
1152 <tr>
1153 <th>Name:
1154 <td><dfn>ruby-span</dfn>
1155 <tr>
1156 <th>Value:
1157 <td>attr(x) | none
1158 <tr>
1159 <th>Initial:
1160 <td>none
1161 <tr>
1162 <th>Applies to:
1163 <td>elements with display: ruby-text
1164 <tr>
1165 <th>Inherited:
1166 <td>no
1167 <tr>
1168 <th>Percentages:
1169 <td>N/A
1170 <tr>
1171 <th>Media:
1172 <td>visual
1173 <tr>
1174 <th>Computed value:
1175 <td><number>
1176 </table>
1178 <p>This property controls the spanning behavior of annotation elements. </p>
1180 <p class="note"><span class="note-label">Note:</span> A XHTML user agent may also use the <samp>rbspan</samp>
1181 attribute to get the same effect.</p>
1183 <p>Possible values:</p>
1185 <dl>
1186 <dt><strong>attr(x)</strong></dt>
1187 <dd>The value of attribute 'x' as a string value. The string value is
1188 evaluated as a <number> to determine the number of ruby base elements to be
1189 spanned by the annotation element. If the <number> is '0', it is replaced by
1190 '1'.The <number> is the computed value. </dd>
1191 <dt>none</dt>
1192 <dd>No spanning. The computed value is '1'.</dd>
1193 </dl>
1195 <p>The following example shows an XML example using the 'display' property
1196 values associated with the 'ruby structure and the 'ruby-span' property</p>
1197 <pre class="xml">myruby { display: ruby; }
1198 myrbc { display: ruby-base-container; }
1199 myrb { display: ruby-base; }
1200 myrtc.before { display: ruby-text-container; ruby-position: before}
1201 myrtc.after { display: ruby-text-container; ruby-position: after}
1202 myrt { display: ruby-text; ruby-span: attr(rbspan); }
1203 ...
1204 <myruby>
1205 <myrbc>
1206 <myrb>10</myrb>
1207 <myrb>31</myrb>
1208 <myrb>2002</myrb>
1209 </myrbc>
1210 <myrtc class="before">
1211 <myrt>Month</myrt>
1212 <myrt>Day</myrt>
1213 <myrt>Year</myrt>
1214 </myrtc>
1215 <myrtc class="after">
1216 <myrt rbspan="3">Expiration Date</myrt>
1217 </myrtc>
1218 </myruby></pre>
1219 -->
1221 <h2 id="default-stylesheet" class="no-num">
1222 Appendix A: Default Style Sheet</h2>
1224 <p><em>This section is informative.</em>
1226 <h3 id="default-ua-ruby" class="no-num">
1227 <span class="secno">A.1</span> Supporting Ruby Layout</h3>
1229 <p>The following represents a default UA style sheet
1230 for rendering HTML and XHTML ruby markup as ruby layout:
1232 <pre>
1233 <!-- -->ruby { display: ruby; }
1234 <!-- -->rb { display: ruby-base; white-space: nowrap; }
1235 <!-- -->rt { display: ruby-text; white-space: nowrap; font-size: 50%; }
1236 <!-- -->rbc { display: ruby-base-container; }
1237 <!-- -->rtc { display: ruby-text-container; }</pre>
1239 <p>Additional rules for UAs supporting the relevant features of [[CSS3-TEXT-DECOR]] and [[CSS3-FONTS]]:
1240 <pre>rt { font-variant-east-asian: ruby; text-emphasis: none; }</pre>
1242 <p class="note">Authors should not use the above rules;
1243 a UA that supports ruby layout should provide these by default.
1245 <h3 id="default-inline" class="no-num">
1246 <span class="secno">A.2</span> Inlining Ruby Annotations</h3>
1248 <p>The following represents a sample style sheet
1249 for rendering HTML and XHTML ruby markup as inline annotations:
1251 <pre>ruby, rb, rt, rbc, rtc, rp {
1252 <!-- --> display: inline; white-space: inherit;
1253 <!-- --> font-variant-east-asian: inherit; text-emphasis: inherit; }</pre>
1255 <h3 id="default-parens" class="no-num">
1256 <span class="secno">A.3</span> Generating Parentheses</h3>
1258 <p>Unfortunately, because Selectors cannot match against text nodes,
1259 it's not possible with CSS to express rules that will automatically and correctly
1260 add parentheses to unparenthesized ruby annotations in HTML.
1261 (This is because HTML ruby allows implying the <i>ruby base</i> from raw text, without a corresponding element.)
1262 However, these rules will handle cases where either <code><rb></code>
1263 or <code><rtc></code> is used rigorously.
1265 <pre>
1266 <!-- -->/* Parens around <rtc> */
1267 <!-- -->rtc::before { content: "("; }
1268 <!-- -->rtc::after { content: ")"; }
1270 <!-- -->/* Parens before first <rt> not inside <rtc> */
1271 <!-- -->rb + rt::before,
1272 <!-- -->rtc + rt::before { content: "("; }
1274 <!-- -->/* Parens after <rt> not inside <rtc> */
1275 <!-- -->rb ~ rt:last-child::after,
1276 <!-- -->rt + rb::before { content: ")"; }
1277 <!-- -->rt + rtc::before { content: ")("; }</pre>
1279 <h2 id="glossary">
1280 Glossary</h2>
1281 <dl>
1282 <dt><a id="g-bopomofo"><strong><span
1283 lang="zh">Bopomofo</span></strong></a></dt>
1284 <dd>37 characters and 4 tone markings used as phonetics in Chinese,
1285 especially standard Mandarin.</dd>
1286 <dt><a id="g-hanja"><strong><span
1287 lang="ko">Hanja</span></strong></a></dt>
1288 <dd>Subset of the Korean writing system that utilizes ideographic
1289 characters borrowed or adapted from the Chinese writing system. Also see
1290 <a href="#g-kanji"><span lang="ja">Kanji</span></a>.</dd>
1291 <dt><a id="g-hiragana"><strong><span
1292 lang="ja">Hiragana</span></strong></a></dt>
1293 <dd>Japanese syllabic script, or character of that script. Rounded and
1294 cursive in appearance. Subset of the Japanese writing system, used together
1295 with kanji and katakana. In recent times, mostly used to write Japanese
1296 words when kanji are not available or appropriate, and word endings and
1297 particles. Also see <a
1298 href="#g-katakana"><span lang="ja">Katakana</span></a>.</dd>
1299 <dt><a id="g-ideogram"><strong>Ideograph</strong></a></dt>
1300 <dd>A character that is used to represent an idea, word, or word component,
1301 in contrast to a character from an alphabetic or syllabic script. The most
1302 well-known ideographic script is used (with some variation) in East Asia
1303 (China, Japan, Korea,...).</dd>
1304 <dt><a id="g-kana"><strong><span lang="ja">Kana</span></strong></a></dt>
1305 <dd>Collective term for hiragana and katakana.</dd>
1306 <dt><a id="g-kanji"><strong>Kanji</strong></a></dt>
1307 <dd>Japanese term for ideographs; ideographs used in Japanese. Subset of the
1308 Japanese writing system, used together with hiragana and katakana. Also see <a
1309 href="#g-hanja"><span lang="ko">Hanja</span></a>.</dd>
1310 <dt><a id="g-katakana"><strong><span
1311 lang="ja">Katakana</span></strong></a></dt>
1312 <dd>Japanese syllabic script, or character of that script. Angular in
1313 appearance. Subset of the Japanese writing system, used together with
1314 kanji and hiragana. In recent times, mainly used to write foreign words. Also see <a
1315 href="#g-hiragana"><span lang="ja">Hiragana</span></a>.</dd>
1316 <dt><a id="g-monoruby" name="g-monoruby"><strong>Mono-ruby</strong></a></dt>
1317 <dd>In Japanese typography: Ruby associated with a single character of
1318 the base text.</dd>
1319 <dt><a id="g-ruby"><strong>Ruby</strong></a></dt>
1320 <dd>A run of text that appears in the vicinity of another run of text and
1321 serves as an annotation or a pronunciation guide for that text.</dd>
1322 </dl>
1324 <h2 id="conformance">
1325 Conformance</h2>
1327 <h3 id="conventions">
1328 Document conventions</h3>
1330 <p>Conformance requirements are expressed with a combination of
1331 descriptive assertions and RFC 2119 terminology. The key words “MUST”,
1332 “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
1333 “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
1334 document are to be interpreted as described in RFC 2119.
1335 However, for readability, these words do not appear in all uppercase
1336 letters in this specification.
1338 <p>All of the text of this specification is normative except sections
1339 explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
1341 <p>Examples in this specification are introduced with the words “for example”
1342 or are set apart from the normative text with <code>class="example"</code>,
1343 like this:
1345 <div class="example">
1346 <p>This is an example of an informative example.</p>
1347 </div>
1349 <p>Informative notes begin with the word “Note” and are set apart from the
1350 normative text with <code>class="note"</code>, like this:
1352 <p class="note">Note, this is an informative note.</p>
1354 <h3 id="conformance-classes">
1355 Conformance classes</h3>
1357 <p>Conformance to CSS Ruby Module
1358 is defined for three conformance classes:
1359 <dl>
1360 <dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
1361 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
1362 style sheet</a>.
1363 <dt><dfn>renderer</dfn></dt>
1364 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1365 that interprets the semantics of a style sheet and renders
1366 documents that use them.
1367 <dt><dfn id="authoring-tool">authoring tool</dfn></dt>
1368 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1369 that writes a style sheet.
1370 </dl>
1372 <p>A style sheet is conformant to CSS Ruby Module
1373 if all of its statements that use syntax defined in this module are valid
1374 according to the generic CSS grammar and the individual grammars of each
1375 feature defined in this module.
1377 <p>A renderer is conformant to CSS Ruby Module
1378 if, in addition to interpreting the style sheet as defined by the
1379 appropriate specifications, it supports all the features defined
1380 by CSS Ruby Module by parsing them correctly
1381 and rendering the document accordingly. However, the inability of a
1382 UA to correctly render a document due to limitations of the device
1383 does not make the UA non-conformant. (For example, a UA is not
1384 required to render color on a monochrome monitor.)
1386 <p>An authoring tool is conformant to CSS Ruby Module
1387 if it writes style sheets that are syntactically correct according to the
1388 generic CSS grammar and the individual grammars of each feature in
1389 this module, and meet all other conformance requirements of style sheets
1390 as described in this module.
1392 <h3 id="partial">
1393 Partial implementations</h3>
1395 <p>So that authors can exploit the forward-compatible parsing rules to
1396 assign fallback values, CSS renderers <strong>must</strong>
1397 treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
1398 as appropriate</a>) any at-rules, properties, property values, keywords,
1399 and other syntactic constructs for which they have no usable level of
1400 support. In particular, user agents <strong>must not</strong> selectively
1401 ignore unsupported component values and honor supported values in a single
1402 multi-value property declaration: if any value is considered invalid
1403 (as unsupported values must be), CSS requires that the entire declaration
1404 be ignored.</p>
1406 <h3 id="experimental">
1407 Experimental implementations</h3>
1409 <p>To avoid clashes with future CSS features, the CSS2.1 specification
1410 reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
1411 syntax</a> for proprietary and experimental extensions to CSS.
1413 <p>Prior to a specification reaching the Candidate Recommendation stage
1414 in the W3C process, all implementations of a CSS feature are considered
1415 experimental. The CSS Working Group recommends that implementations
1416 use a vendor-prefixed syntax for such features, including those in
1417 W3C Working Drafts. This avoids incompatibilities with future changes
1418 in the draft.
1419 </p>
1421 <h3 id="testing">
1422 Non-experimental implementations</h3>
1424 <p>Once a specification reaches the Candidate Recommendation stage,
1425 non-experimental implementations are possible, and implementors should
1426 release an unprefixed implementation of any CR-level feature they
1427 can demonstrate to be correctly implemented according to spec.
1429 <p>To establish and maintain the interoperability of CSS across
1430 implementations, the CSS Working Group requests that non-experimental
1431 CSS renderers submit an implementation report (and, if necessary, the
1432 testcases used for that implementation report) to the W3C before
1433 releasing an unprefixed implementation of any CSS features. Testcases
1434 submitted to W3C are subject to review and correction by the CSS
1435 Working Group.
1437 <p>Further information on submitting testcases and implementation reports
1438 can be found from on the CSS Working Group's website at
1439 <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
1440 Questions should be directed to the
1441 <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
1442 mailing list.
1444 <h2 class=no-num id="acknowledgments">
1445 Acknowledgments</h2>
1447 <p>This specification would not have been possible without the help from:</p>
1449 <p>Stephen Deach, Martin Dürst, Hideki Hiura(<span lang="ja">樋浦 秀樹</span>), Masayasu Ishikawa(<span lang="ja">石川
1450 雅康</span>), Chris
1451 Pratley, Takao Suzuki(<span lang="ja">鈴木 孝雄</span>), Frank Yung-Fong Tang, Chris Thrasher, Masafumi Yabe<span lang="ja">家辺
1452 勝文</span>), Steve Zilles.</p>
1454 <h2 class="no-num" id="changes">
1455 Changes</h2>
1457 <p>The following major changes have been made since the previous Working Draft:
1458 <dl>
1459 <dt>Remove 'ruby-span' and mentions of <code>rbspan</code>.
1460 <dd>
1461 Explicit spanning is not used in HTML ruby in favor of implicit spanning.
1462 This can't handle some pathological double-sided spanning cases,
1463 but there seems to be no requirement for these at the moment.
1464 (For implementations that support full complex XHTML Ruby,
1465 they can imply spanning from the markup the same magic way
1466 that we handle cell spanning from tables. It doesn't seem
1467 necessary to include controls this in Level 1.)
1469 <dt>Defer 'ruby-overhang' and ''ruby-align: line-end'' to Level 2.
1470 <dd>
1471 It's somewhat complicated, advanced feature.
1472 Proposal is to make this behavior UA-defined
1473 and provide some examples of acceptable options.
1475 <dt>Close issue requesting 'display: rp': use ''display: none''.
1476 <dd>
1477 The i18nwg added an issue requesting a display value for <rp> elements.
1478 They're supposed to be hidden when &tl;ruby> is displayed as ruby.
1479 But this is easily accomplished already with ''display: none''.
1481 <dt>Change 'ruby-position' values to match 'text-emphasis-position'.
1482 <dd>
1483 Other than ''inter-character'', which we need to keep,
1484 it makes more sense to align ruby positions with 'text-emphasis-position',
1485 which can correctly handle various combinations of horizontal/vertical preferences.
1487 <dt>Remove unused values of 'ruby-align'.
1488 <dd>
1489 'left', 'right', and 'end' are not needed.
1491 <dt>Added 'ruby-merge' property to control jukugo rendering.
1492 <dd>
1493 This is a stylistic effect, not a structural one;
1494 the previous model assumed that it was structural and suggested handling it by changing markup. :(
1496 <dt>Remove ''inline'' from 'ruby-position'.
1497 <dd>
1498 This is do-able via ''display: inline'' on all the ruby-related elements,
1499 see <a href="#default-inline">Appendix A</a>
1501 <dt>Added <a href="#default-style">Default Style</a> rules
1502 <dd>
1503 As requested by i18nwg.
1505 <dt>Wrote anonymous box generation rules
1506 <dd>
1507 And defined pairing of bases and annotations.
1508 Should now handle all the crazy proposed permutations of HTML ruby markup.
1509 </dl>
1511 <h2 class=no-num id="references">
1512 References</h2>
1514 <h3 class="no-num" id="normative-references">
1515 Normative references</h3>
1516 <!--normative-->
1518 <h3 class="no-num" id="other-references">
1519 Other references</h3>
1520 <!--informative-->
1522 <h2 class="no-num" id="index">
1523 Index</h2>
1524 <!--index-->
1526 <h2 class="no-num" id="property-index">
1527 Property index</h2>
1528 <!-- properties -->
1530 </body>
1531 </html>
1532 <!-- Keep this comment at the end of the file
1533 Local variables:
1534 mode: sgml
1535 sgml-declaration:"~/SGML/HTML4.decl"
1536 sgml-default-doctype-name:"html"
1537 sgml-minimize-attributes:t
1538 sgml-nofill-elements:("pre" "style" "br")
1539 sgml-live-element-indicator:t
1540 sgml-omittag:nil
1541 sgml-shorttag:nil
1542 sgml-namecase-general:t
1543 sgml-general-insert-case:lower
1544 sgml-always-quote-attributes:t
1545 sgml-indent-step:nil
1546 sgml-indent-data:t
1547 sgml-parent-document:nil
1548 sgml-exposed-tags:nil
1549 sgml-local-catalogs:nil
1550 sgml-local-ecat-files:nil
1551 End:
1552 -->