Mon, 24 Jun 2013 17:43:42 -0700
[css-ruby] Define auto-hiding behavior for handling furigana.
1 <!--
3 Issues:
4 white space
5 line breaking
6 bidi
8 Redo all examples with consistent font. (M+ 2p?)
10 -->
12 <!DOCTYPE html>
13 <html lang="en">
14 <head>
15 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
16 <title>CSS Ruby Module Level 1</title>
17 <link rel=contents href="#contents">
18 <link rel=index href="#index">
19 <link rel="stylesheet" type="text/css" href="../default.css">
20 <link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
21 <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
22 </head>
24 <body class="h-entry">
26 <div class="head">
27 <!--logo-->
29 <h1 class="p-name">CSS Ruby Module Level 1</h1>
31 <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>
32 <dl>
33 <dt>This version:
34 <dd><a class="u-url" href="[VERSION]">[VERSION]</a>
36 <dt>Latest version:
37 <dd><a href="http://www.w3.org/TR/[SHORTNAME]/">http://www.w3.org/TR/css3-ruby/</a>
39 <dt>Editor's draft:
40 <dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
41 (<a href="https://dvcs.w3.org/hg/csswg/log/tip/[SHORTNAME]/Overview.src.html">change log</a>)
43 <dt>Previous version:
44 <dd><a href="http://www.w3.org/TR/2011/WD-css3-ruby-20110630/">
45 http://www.w3.org/TR/2011/WD-css3-ruby-20110630/</a>
47 <dt>Issue Tracking:</dt>
48 <dd><a rel="issues" href="http://www.w3.org/Style/CSS/Tracker/products/FIXME">http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
50 <dt>Feedback:</dt>
51 <dd><a href="mailto:www-style@w3.org?subject=%5BSHORTNAME%5D%20feedback"
52 >www-style@w3.org</a>
53 with subject line “<kbd>[[SHORTNAME]]
54 <var>… message topic …</var></kbd>”
55 (<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/"
56 >archives</a>)
58 <dt>Editors:
59 <dd class="p-author h-card vcard">
60 <a class="p-name fn u-url url" rel="author"
61 href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a>,
62 <a class="p-org org h-org" href="http://www.mozilla.org/">Mozilla</a>
63 <dd class="p-author h-card vcard">
64 <a class="p-name fn u-url url" rel="author"
65 href="mailto:koji.a.ishii@mail.rakuten.com">Koji Ishii</a>,
66 <span class="p-org org">Rakuten, Inc.</span>
67 <dd class="p-author h-card vcard">
68 <a class="p-name fn u-url url" rel="author"
69 href="mailto:ishida@w3.org">Richard Ishida</a>,
70 <span class="p-org org">W3C</span>
72 <dt>Former editors:
73 <dd>Michel Suignard, Microsoft
74 <dd>Marcin Sawicki, Microsoft
75 </dl>
77 <!--copyright-->
79 <hr title="Separator for header">
80 </div>
82 <h2 class="no-num no-toc" id="abstract">Abstract</h2>
84 <p>
85 <span class="p-summary">
86 “Ruby” are short runs of text alongside the base text,
87 typically used in East Asian documents to indicate pronunciation
88 or to provide a short annotation.
89 This module describes the rendering model and formatting controls
90 related to displaying ruby annotations in CSS.
91 </span>
93 <a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing
94 the rendering of structured documents (such as HTML and XML) on screen, on
95 paper, in speech, etc.
97 <h2 class="no-num no-toc" id="status">Status of this document</h2>
99 <!--status-->
101 <p>The following features are at risk: …
103 <h2 class="no-num no-toc" id="contents">
104 Table of Contents</h2>
106 <!--toc-->
108 <h2 id="intro">
109 Introduction</h2>
111 <p><em>This section is not normative.</em>
113 <h3 id="placement">
114 Module interactions</h3>
116 <p>This module extends the inline box model of CSS Level 2 [[!CSS21]]
117 to support ruby.
119 <p>None of the properties in this module apply to the <code>::first-line</code> or
120 <code>::first-letter</code> pseudo-elements.
122 <h3 id="values">
123 Values</h3>
125 <p>This specification follows the
126 <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
127 definition conventions</a> from [[!CSS21]]. Value types not defined in
128 this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
129 Other CSS modules may expand the definitions of these value types: for
130 example [[CSS3VAL]], when combined with this module, expands the
131 definition of the <var><length></var> value type as used in this specification.</p>
133 <p>In addition to the property-specific values listed in their definitions,
134 all properties defined in this specification also accept the
135 <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
136 keyword as their property value. For readability it has not been repeated
137 explicitly.
139 <h3 id="conventions">
140 Document conventions</h3>
142 <p>Many typographical conventions in East Asian typography depend
143 on whether the character rendered is wide (CJK) or narrow (non-CJK).
144 There are a number of illustrations in this document
145 for which the following legend is used:
147 <dl>
148 <dt><img alt="Symbolic wide-cell glyph representation" width="39" height="39" src="images/fullwidth.gif">
149 <dd>Wide-cell glyph (e.g. Han) that is the <var>n</var>th character in the text run.
150 They are typically sized to 50% when used as annotations.
151 <dt><img alt="Symbolic narrow-cell glyph representation" width="19" height="39" src="images/halfwidth.gif">
152 <dd>Narrow-cell glyph (e.g. Roman) which is the <var>n</var>th glyph in the text run.
153 </dl>
155 <p>The orientation which the above symbols assume in the diagrams
156 corresponds to the orientation that the glyphs they represent
157 are intended to assume when rendered by the user agent.
158 Spacing between these characters in the diagrams is incidental,
159 unless intentionally changed to make a point.
161 <h3 id="ruby-def">
162 What is ruby?</h3>
164 <p><dfn>Ruby</dfn> is the commonly-used name for a run of text
165 that appears alongside another run of text (referred to as the “base”)
166 and serves as an annotation or a pronunciation guide associated with that run of text.
168 <p>The following figures show two examples of Ruby,
169 a simple case and one with more complicated structure.
171 <div class="example">
172 <p>In this first example, a single annotation is used to annotate the base text.
173 <div class="figure">
174 <p><img src="images/licence.png"
175 alt="Example of ruby applied on top of a Japanese expression">
176 <p class="caption">Example of ruby used in Japanese (simple case)
177 </div>
178 <p>In Japanese typography, this case is sometimes called
179 <i lang="ja">taigo</i> ruby or group-ruby (per-word ruby),
180 because the annotation as a whole is associated
181 with multi-character word (as a whole).
182 </div>
184 <div class="example">
185 <p>In this second example,
186 two levels of annotations are attached to a base sequence:
187 the hiragana characters on top refer to the pronunciation of each of the base kanji characters,
188 while the words “Keio” and “University” on the bottom are annotations describing the English translation.
189 <div class="figure">
190 <p><img src="images/ruby-univ.gif"
191 alt="Example showing complex ruby with annotation text over and under the base characters">
192 <p class="caption">Complex ruby with annotation text over and under the base characters
193 </div>
194 <p>
195 <p>Notice that to allow correct association between the hiragana characters and
196 their corresponding Kanji base characters,
197 the spacing between these Kanji characters is adjusted.
198 (This happens around the fourth Kanji character in the figure above.)
199 To avoid variable spacing between the Kanji characters in the example above
200 the hiragana annotations can be styled as a <i>collapsed annotation</i>,
201 which will look more like the group-ruby example earlier.
202 However because the base-annotation pairings are recorded in the ruby structure,
203 if the text breaks across lines, the annotation characters will stay
204 correctly paired with their respective base characters.
205 </div>
207 <p><i>Ruby</i> formatting as used in Japanese is described in JIS X-4051 [[JIS4051]] (in Japanese)
208 and in Requirements for Japanese Text Layout [[JLREQ]] (in English and Japanese)].
209 In HTML, ruby structure and markup to represent it is described
210 in the Ruby Markup Extension specification.
211 This module describes the CSS rendering model
212 and formatting controls relevant to ruby layout of such markup.
214 <h2 id="ruby-model">
215 Ruby Formatting Model</h2>
217 <p>The CSS ruby model is based on
218 the <a href="http://darobin.github.io/html-ruby/">HTML Ruby Markup Extension</a>
219 and <a href="http://www.w3.org/TR/ruby/">XHTML Ruby Annotation Recommendation</a> [[RUBY]].
220 In this model, a ruby structure consists of
221 one or more <dfn>ruby base</dfn> elements representing the base (annotated) text,
222 associated with one or more levels of <dfn>ruby annotation</dfn> elements representing the annotations.
223 The structure of ruby is similar to that of a table:
224 there are “rows” (the base text level, each annotation level)
225 and “columns” (each <i>ruby base</i> and its corresponding <i>ruby annotations</i>).
227 <p>Consecutive bases and annotations are grouped together into <dfn>ruby segments</dfn>.
228 Within a <i>ruby segment</i>, a <i>ruby annotation</i> may span multiple <i>ruby bases<i>.
230 <p class="note">In HTML, a single <code><ruby></code> element may contain multiple <i>ruby segments</i>.
231 (In the XHTML Ruby model, a single <code><ruby></code> element can only contain one <i>ruby segment</i>.)
233 <h3 id="ruby-display">
234 Ruby-specific 'display' property values</h3>
236 <p>For document languages (such as XML applications) that do not have pre-defined ruby elements,
237 authors must map document language elements to ruby elements;
238 this is done with the 'display' property.
240 <table class="propdef">
241 <tr>
242 <th>Name:
243 <td>display
244 <tr>
245 <th><a href="#values">New Values</a>:
246 <td>ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container
247 </table>
249 <p>The following new 'display' values assign ruby layout roles to an arbitrary element:
251 <dl>
252 <dt>''ruby''
253 <dd>Specifies that an element generates a <dfn title="ruby container | ruby container box">ruby container box</dfn>.
254 (Corresponds to HTML/XHTML <code><ruby></code> elements.)
255 <dt>''ruby-base''
256 <dd>Specifies that an element generates a <dfn title="ruby base box | ruby base">ruby base box</dfn>.
257 (Corresponds to HTML/XHTML <code><rb></code> elements.)
258 <dt>''ruby-text''
259 <dd>Specifies that an element generates a <dfn title="ruby annotation box | ruby annotation">ruby annotation box</dfn>.
260 (Corresponds to HTML/XHTML <code><rt></code> elements.)
261 <dt>''ruby-base-container''
262 <dd>Specifies that an element generates a <dfn title="ruby base container box | ruby base container">ruby base container box</dfn>.
263 (Corresponds to XHTML <code><rbc></code> elements; always implied in HTML.)
264 <dt>''ruby-text-container''
265 <dd>Specifies that an element generates a <dfn title="ruby annotation container box | ruby annotation container">ruby annotation container box</dfn>.
266 (Corresponds to HTML/XHTML <code><ruby></code> elements.)
267 </dl>
269 <h3 id="box-fixup">
270 Anonymous Ruby Box Generation</h3>
272 <p>The CSS model does not require that the document language
273 include elements that correspond to each of these components.
274 Missing parts of the structure are implied through the anonymous box generation rules
275 <a href="http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes">similar to those used to normalize tables</a>. [[!CSS21]]
277 <ol>
278 <li>Any in-flow block-level boxes directly contained by a
279 <i>ruby container</i>,
280 <i>ruby base container</i>,
281 <i>ruby annotation container</i>,
282 <i>ruby base box</i>,
283 or <i>ruby annotation box</i>
284 are forced to be inline-level boxes,
285 and their 'display' value computed accordingly.
286 For example,
287 the 'display' property of an in-flow element with ''display: block''
288 parented by an element with ''display: ruby-text''
289 computes to ''inline-block''.
290 This computation occurs after any intermediary anonymous-box fixup
291 (such as that required by internal table elements).
293 <li>Any consecutive sequence of <i>ruby bases</i> not parented by a <i>ruby base container</i>
294 is wrapped in an anonymous <i>ruby base container</i>.
295 Similarly, any consecutive sequence of <i>ruby annotations</i> not parented by a <i>ruby annotation container</i>
296 is wrapped in an anonymous <i>ruby annotation container</i>.
298 <li>Within each <i>ruby base container</i>,
299 each sequence of inline-level boxes is wrapped in an anonymous <i>ruby base box</i>.
300 Similarly, within each <i>ruby annotation container</i>,
301 each sequence of inline-level boxes is wrapped in an anonymous <i>ruby annotation box</i>.
303 <li>A sequence of <i>ruby base containers</i> and/or <i>ruby annotation containers</i>
304 not parented by a <i>ruby container</i>
305 is wrapped in an anonymous <i>ruby container</i>.
306 </ol>
308 <p>At this point, all ruby layout structures are properly parented,
309 and the UA can start to associate bases with their annotations.
311 <p class="note">
312 Note that the UA is not required to create any of these anonymous boxes in its internal structures,
313 as long as pairing and layout behaves as if they existed.
315 <h3 id="pairing">
316 Ruby Pairing and Annotation Levels</h3>
318 <p>Within a ruby structure,
319 each <i>ruby bases</i> are associated with <i>ruby annotations</i>
320 and vice versa.
321 A <i>ruby base</i> can be associated with at most one <i>ruby annotation</i> per annotation level.
322 If there are multiple annotation levels, it can therefore be associated with multiple <i>ruby annotations</i>.
323 A <i>ruby annotation</i> is associated with one or more <i>ruby bases</i>;
324 annotations can span multiple bases.
326 <p><dfn>Annotation pairing</dfn> is the process of associating
327 <i>ruby annotations</i> with <i>ruby bases</i>.
329 <ol>
330 <li>
331 <p>First, the ruby structure is divided into <i>ruby segments</i>,
332 each consisting of a single <i>ruby base container</i>
333 followed by one or more <i>ruby annotation containers</i>.
334 If the first child of a <i>ruby container</i> is a <i>ruby annotation container</i>,
335 an anonymous, empty <i>ruby base container</i> is assumed to exist before it.
336 Similarly, if the <i>ruby container</i> contains consecutive <i>ruby base containers</i>,
337 anonymous, empty <i>ruby annotation containers</i> are assumed to exist between them.
338 The <i>ruby base container</i> in each segment is thus associated
339 with each of the <i>ruby annotation containers</i> in that segment.
341 <p>Each <i>ruby annotation containers</i> in a <i>ruby segment</i>
342 represents one <dfn title="annotation level | level">level</dfn> of annotation:
343 the first one represents the first level of annotation,
344 the second one represents the second level of annotation,
345 and so on.
347 <li>Within each <i>ruby segment</i>,
348 each <i>ruby base box</i> in the <i>ruby base container</i>
349 is paired with one <i>ruby annotation box</i>
350 from each <i>ruby annotation container</i> in its <i>ruby segment</i>.
351 If there are not enough <i>ruby annotations</i> in a <i>ruby annotation container</i>,
352 the last one is associated with any excess <i>ruby bases</i>.
353 (If there are not any in the <i>ruby annotation container</i>, an anonymous empty one is assumed to exist.)
354 If there are not enough <i>ruby bases</i>,
355 any remaining <i>ruby annotations</i> are assumed to be associated
356 with empty, anonymous bases inserted at the end of the <i>ruby base container</i>.
358 <p>If an implementation supports ruby markup with explicit spanning
359 (e.g. XHTML Complex Ruby Annotations),
360 it must adjust the pairing rules to pair spanning annotations to multiple bases
361 appropriately.
362 </ol>
364 <p>A this point, ruby “columns” are defined,
365 each represented by a single <i>ruby base</i>
366 and associated with one <i>ruby annotation</i> (possibly an empty, anonymous one)
367 from each <i>annotation level</i>.
369 <h4 id="nested-pairing">
370 Nested Ruby</h4>
372 <p>When <i>ruby containers</i> are nested,
373 pairing begins with the deepest <i>ruby container</i>,
374 then expands out,
375 treating each <i>ruby container</i> nested within another <i>ruby container</i>
376 as a <i>ruby base</i>,
377 and associating each <i>ruby annotation</i>
378 associated with the nested <i>ruby container</i>
379 as being associated with (spanning) all of its <i>ruby bases</i>.
381 <p>Using nested <i>ruby containers</i> thus allows the representation
382 of complex spanning relationships.
384 <p class="issue">This shouldn't belong in Level 1. But HTML5 allows it, so we have to handle it. Yay HTML5.
386 <h3 id="autohide">
387 Autohiding Annotations</h3>
389 <p>If a <i>ruby annotation</i> has the exact same content as its base,
390 it is <dfn title="hidden ruby annotation | hidden annotation">hidden</dfn>.
391 Hiding a <i>ruby annotation</i> does not affect annotation pairing
392 or the block-axis positioning of boxes in other <i>levels</i>.
393 However the <i>hidden annotation</i> is not visible,
394 and it has no impact on layout
395 other than to separate adjacent sequences of <i>ruby annotation boxes</i> within its level,
396 as if they belonged to separate segments
397 and the <i>hidden annotation</i>’s base were not a <i>ruby base</i> but an intervening inline.
399 <div class="example">
400 <p>This is to allow correct inlined display of annotations
401 for Japanese words that are a mix of kanji and hirangana.
402 For example, the word <i>振り仮名</i> should be inlined as
403 <p class="figure">振り仮名(ふりがな)
404 <p>and therefore marked up as
405 <pre>
406 <!-- --><ruby>
407 <!-- --> <rb>振</rb><rb>り</rb><rb>仮</rb><rb>名</rb>
408 <!-- --> <rp>(</rp><rt>ふ</rt><rt>り</rt><rt>が</rt><rt>な</rt><rp>)</rp>
409 <!-- --><ruby></pre>
410 <p>However, when displayed as ruby, the “り” should be hidden
411 <div class="figure">
412 <p><img src="images/furigana-separate.png"
413 alt="Hiragana annotations for 振り仮名 appear, each above its base character.">
414 <p class="caption">Hiragana ruby for 振り仮名
415 </div>
416 </div>
418 <p class="note">
419 Future levels of CSS Ruby may add controls for this,
420 however in this level it is always forced.
422 <p>The content comparison for this auto-hiding behavior
423 takes place prior to white space collapsing.
424 <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.
426 <h3 id="white-space">
427 White Space</h3>
429 <p class="issue">I'm unsure exactly where space should be trimmed. :/
430 But pretty sure we need to keep spaces between things,
431 otherwise ruby only works for CJK.
433 <p><i>Collapsible</i> white space within a ruby structure is discarded
434 at the beginning and end of a <i>ruby container</i>,
435 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.
436 Between <i>ruby segments</i>, between <i>ruby bases</i>, and between <i>ruby annotations</i>, however,
437 white space is not discarded.
438 If such white space is <i>collapsible</i>, it will collapse
439 following the standard <a href="http://www.w3.org/TR/css3-text/#white-space-rules">white space processing rules</a>. [[!CSS3-TEXT]]
440 Between <i>ruby segments</i>, however,
441 the contextual text for determining collapsing behavior is given by the <i>ruby bases</i> on either side,
442 not the text on either side of the white space in the source document.
444 <div class="note">
445 <p>Note that the white space processing rules
446 cause a white space sequence containing a <i>segment break</i> (such as a line feed)
447 to <a href="http://www.w3.org/TR/css3-text/#line-break-transform">collapse to nothing</a> between CJK characters.
448 This means that CJK ruby can safely use white space for indentation of the ruby markup.
449 For example, the following markup will display without any spaces:
450 <pre>
451 <!-- --><ruby>
452 <!-- --> <rb>東</rb><rb>京</rb>
453 <!-- --> <rt>とう</rt><rt>きょう</rt>
454 <!-- --></ruby></pre>
455 <p>However, this markup will:
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="ruby-line-height">
536 Ruby box and line stacking</h3>
538 <div class="figure">
539 <p>
540 <img class="example"
541 alt="Diagram showing the ruby text using 2 half leading"
542 src="images/rlh-a.gif" width="210" height="138" /></p>
544 <p><b>Figure 3.3.1</b>: Excluded Ruby text</p>
545 </div>
546 -->
548 <h2 id="ruby-props">
549 Ruby Properties</h2>
551 <p>The following properties are introduced to control ruby positioning and alignment.
553 <h3 id="rubypos">
554 Ruby positioning: the 'ruby-position' property</h3>
556 <table class="propdef">
557 <tr>
558 <th>Name:
559 <td><dfn>ruby-position</dfn>
560 <tr>
561 <th><a href="#values">Value</a>:
562 <td>[ over | under | inter-character ] && [ right | left ]
563 <tr>
564 <th>Initial:
565 <td>over right
566 <tr>
567 <th>Applies to:
568 <td>ruby annotation containers
569 <tr>
570 <th>Inherited:
571 <td>yes
572 <tr>
573 <th>Percentages:
574 <td>N/A
575 <tr>
576 <th>Media:
577 <td>visual
578 <tr>
579 <th>Computed value:
580 <td>specified value
581 <tr>
582 <th>Animatable:
583 <td>no
584 <tr>
585 <th>Canonical order:
586 <td><abbr title="follows order of property value definition">per grammar</abbr>
587 </table>
589 <p>This property controls position of the ruby text with respect to its base.
590 Values have the following meanings:
592 <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>
593 <dl>
594 <dt><dfn title="ruby-position:over">''over''</dfn>
595 <dd>The ruby text appears <i>over</i> the base in horizontal text.
597 <div class="figure">
598 <p><img src="images/shinkansen-top.gif"
599 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing above the base">
600 <p class="caption">Ruby over Japanese base text in horizontal layout
601 </div>
602 </dd>
604 <dt><dfn title="ruby-position:right">''right''</dfn>
605 <dd>The ruby text appears on the right side of the base in vertical text.
606 <div class="figure">
607 <p><img src="images/shinkansen-right.gif" width="33"
608 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the right of the base">
609 <p class="caption">Ruby to the right of Japanese base text in vertical layout
610 </div>
611 </dd>
613 <dt><dfn title="ruby-position:under">''under''</dfn>
614 <dd>The ruby text appears under the base in horizontal text.
615 This is a relatively rare setting used in ideographic East Asian writing systems,
616 most easily found in educational text.
618 <div class="figure">
619 <p><img src="images/shinkansen-bottom.gif"
620 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing below the base">
621 <p class="caption">Ruby under Japanese base text in horizontal layout
622 </div>
623 </dd>
625 <dt><dfn title="ruby-position:left">''left''</dfn>
626 <dd>The ruby text appears on the left side of the base in vertical text.
628 <div class="figure">
629 <p><img src="images/shinkansen-left.gif"
630 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the left of the base">
631 <p class="caption">Ruby to the left of Japanese base text in vertical layout
632 </div>
633 </dd>
635 <dt><dfn title="ruby-position:inter-character">''inter-character''</dfn></dt>
636 <dd>
637 <p>The ruby text appears on the right of the base in horizontal text.
638 This value forces the 'writing-mode' of the <i>ruby annotation</i> to be vertical.
640 <p>This value is provided for the special case of traditional Chinese
641 as used especially in Taiwan:
642 ruby (made of <a href="#g-bopomofo">bopomofo</a> glyphs) in that context
643 appears vertically along the right side of the base glyph,
644 even when the layout of the base characters is horizontal:
646 <div class="figure">
647 <p><img src="images/bopomofo.gif"
648 alt="Example of Taiwanese-style ruby">
649 <p class="caption">“Bopomofo” ruby in traditional Chinese
650 (ruby text shown in blue for clarity) in horizontal layout
651 </div>
652 <p class="note">
653 Note that the user agent is responsible for ensuring the correct relative alignment and positioning of the glyphs,
654 including those corresponding to the tone marks, when displaying.
655 Tone marks are spacing characters that occur (in memory) at the end of the ruby text for each base character.
656 They are usually displayed in a separate column to the right of the bopomofo characters,
657 and the height of the tone mark depends on the number of characters in the syllable.
658 One tone mark, however, is placed above the bopomofo, not to the right of it.
659 <!-- See Taiwanese requirements doc for EPUB at http://epub-revision.googlecode.com/files/EGLS_TW_eng.ppt -->
660 </dd>
661 </dl>
663 <p>If multiple <i>ruby annotation containers</i> have the same 'ruby-position',
664 they stack along the block axis,
665 with lower levels of annotation closer to the base text.
667 <h3 id="collapsed-ruby">
668 Collapsed Ruby Annotations: the 'ruby-merge' property</h3>
670 <table class="propdef">
671 <tr>
672 <th>Name:
673 <td><dfn>ruby-merge</dfn>
674 <tr>
675 <th><a href="#values">Value</a>:
676 <td>separate | collapse | auto
677 <tr>
678 <th>Initial:
679 <td>separate
680 <tr>
681 <th>Applies to:
682 <td>ruby annotation containers
683 <tr>
684 <th>Inherited:
685 <td>yes
686 <tr>
687 <th>Percentages:
688 <td>N/A
689 <tr>
690 <th>Media:
691 <td>visual
692 <tr>
693 <th>Computed value:
694 <td>specified value
695 <tr>
696 <th>Animatable:
697 <td>no
698 <tr>
699 <th>Canonical order:
700 <td><abbr title="follows order of property value definition">per grammar</abbr>
701 </table>
703 <p>
704 This property controls how ruby annotation boxes should be rendered
705 when there are more than one in a ruby container box.
707 <p>Possible values:</p>
708 <dl>
709 <dt><dfn title="ruby-merge:separate">''separate''</dfn>
710 <dd>
711 <p>
712 Each ruby annotation box is rendered in the same column(s) as its corresponding base box(es).
713 This style is called “mono ruby” in [[JLREQ]].
715 <div class="example">
716 <p>For example, the following two markups render the same:
717 <pre><ruby>無<rt>む</ruby><ruby>常<rt>じょう</ruby></pre>
718 <p>and:
719 <pre><ruby style="ruby-merge:separate"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
720 </div>
721 </dd>
723 <dt><dfn title="ruby-merge:collapse">''collapse''</dfn>
724 <dd>
725 <p>
726 All <i>ruby annotation boxes</i> within the same <i>ruby segment</i> on the same line are concatenated,
727 and laid out as if their contents belonged to a single <i>ruby annotation box</i>
728 spanning all their associated <i>ruby base boxes.
729 This style renders similar to “group ruby” in [[JLREQ]],
730 except that <i>ruby annotations</i> are kept together with their respective <i>ruby bases</i> when breaking lines.
731 </p>
733 <div class="example">
734 <p>The following two markups render the same both characters fit on one line:
735 <pre><ruby>無常<rt>むじょう</ruby></pre>
736 <p>and:
737 <pre><ruby style="ruby-merge:collapse"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
738 <p>However, the second one renders the same as ''ruby-position: separate''
739 when the two bases are split across lines.
740 </div>
741 </dd>
743 <dt><dfn title="ruby-merge:auto">''auto''</dfn></dt>
744 <dd>
745 <p>
746 The user agent may use any algorithm to determine how each ruby annotation box
747 is rendered to its corresponding base box.
748 <div class="example">
749 <p>
750 One possible algorithm is described as Jukugo-ruby in [[JLREQ]].
751 <p>
752 Another, more simplified algorithm of Jukugo-ruby is
753 to render as Mono-ruby if all ruby annotation boxes fit within
754 advances of their corresponding base boxes,
755 and render as Group-ruby otherwise.
756 </p>
757 </div>
758 </dd>
759 </dl>
761 <h3 id="rubyalign">
762 Ruby Text Distribution: the 'ruby-align' property</h3>
764 <table class="propdef">
765 <tr>
766 <th>Name:
767 <td><dfn>ruby-align</dfn>
768 <tr>
769 <th><a href="#values">Value</a>:
770 <td>auto | start | center |
771 distribute-letter | distribute-space
772 <tr>
773 <th>Initial:
774 <td>auto
775 <tr>
776 <th>Applies to:
777 <td>ruby bases, ruby annotations, ruby base containers, ruby annotation containers
778 <tr>
779 <th>Inherited:
780 <td>yes
781 <tr>
782 <th>Percentages:
783 <td>N/A
784 <tr>
785 <th>Media:
786 <td>visual
787 <tr>
788 <th>Computed value:
789 <td>specified value (except for initial and inherit)
790 </table>
792 <p>This property specifies how text is distributed within the various ruby boxes
793 when their text contents exactly fill their respective boxes.
795 <p>Values have the following meanings:
796 <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>
797 <dl>
798 <dt><dfn title="ruby-align:auto">''auto''</dfn></dt>
799 <dd>
800 <p>The user agent determines how the ruby contents are aligned.
801 This is the initial value.
802 The behavior recommended by [[JLREQ]] is for wide-cell ruby to be aligned in the 'distribute-space' mode:
803 <div class="figure">
804 <p><img width="145" height="91"
805 alt="Diagram of glyph layout in auto aligned ruby when ruby text is shorter than base"
806 src="images/ra-ds.gif" /><img width="145" height="91"
807 alt="Diagram of glyph layout in auto aligned ruby when ruby text is longer than base"
808 src="images/ra-ds-rb.gif" /></p>
809 <p><b>Figure 4.2.1</b>: Wide-cell text in 'auto' ruby alignment is
810 'distribute-space' justified</p>
811 </div>
813 <p>The recommended behavior for narrow-cell glyph ruby is to be
814 aligned in the 'center' mode.</p>
815 <div class="figure">
816 <p><img
817 alt="Diagram of glyph layout in auto aligned ruby when halfwidth ruby text is shorter than base"
818 width="145" height="91"
819 src="images/ra-c-h.gif" /><img
820 alt="Diagram of character layout in auto aligned ruby when ruby text is longer than narrow-width base"
821 width="145" height="91"
822 src="images/ra-c-rb-h.gif" /></p>
823 <p><b>Figure 4.2.2</b>: Narrow-width ruby text in 'auto' ruby alignment
824 is centered</p>
825 </div>
826 </dd>
828 <dt><dfn title="ruby-align:start">''start''</dfn></dt>
829 <dd>The ruby annotation content is aligned with the start edge of the base.
830 <div class="figure">
831 <p><img
832 alt="Diagram of glyph layout in left aligned ruby when ruby text is shorter than base"
833 width="145" height="91" src="images/ra-l.gif" /><img
834 width="145" height="91"
835 alt="Diagram of glyph layout in left aligned ruby when ruby text is longer than base"
836 src="images/ra-l-rb.gif" /></p>
837 <p><b>Figure 4.2.3</b>: Start ruby alignment</p>
838 </div>
839 </dd>
841 <dt><dfn title="ruby-align:center">''center''</dfn></dt>
842 <dd>The ruby text content is centered within the width of the base. If the
843 length of the base is smaller than the length of the ruby text, then the
844 base is centered within the width of the ruby text.
846 <div class="figure">
847 <p><img width="145" height="91"
848 alt="Diagram of glyph layout in center aligned ruby when ruby text is shorter than base"
849 src="images/ra-c.gif" /><img width="145" height="91"
850 alt="Diagram of glyph layout in center aligned ruby when ruby text is longer than base"
851 src="images/ra-c-rb.gif" /></p>
852 <p><b>Figure 4.2.4</b>: Center ruby alignment</p>
853 </div>
854 </dd>
856 <!--
857 <dt><strong>right</strong></dt>
858 <dd>The ruby text content is aligned with the end edge of the base.
859 <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>
860 <div class="figure">
861 <p><img class="example" width="145" height="91"
862 alt="Diagram of glyph layout in right aligned ruby when ruby text is shorter than base"
863 src="images/ra-r.gif" /><img class="example" width="145" height="91"
864 alt="Diagram of glyph layout in right aligned ruby when ruby text is longer than base"
865 src="images/ra-r-rb.gif" /></p>
866 <p><b>Figure 4.2.5</b>: End ruby alignment</p>
867 </div>
868 </dd>
869 -->
871 <dt><dfn title="ruby-align:distribute-letter">''distribute-letter''</dfn></dt>
872 <dd>If the width of the ruby text is smaller than that of the base, then
873 the ruby text contents are evenly distributed across the width of the
874 base, with the first and last ruby text glyphs lining up with the
875 corresponding first and last base glyphs. If the width of the ruby text
876 is at least the width of the base, then the letters of the base are
877 evenly distributed across the width of the ruby text.
879 <div class="figure">
880 <p><img width="145" height="91"
881 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is shorter than base"
882 src="images/ra-dl.gif" /><img width="145" height="91"
883 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is longer than base"
884 src="images/ra-dl-rb.gif" /></p>
885 <p><b>Figure 4.2.6</b>: Distribute-letter ruby alignment</p>
886 </div>
887 </dd>
889 <dt><dfn title="ruby-align:distribute-space">''distribute-space''</dfn></dt>
890 <dd>If the width of the ruby text is smaller than that of the base, then
891 the ruby text contents are evenly distributed across the width of the
892 base, with a certain amount of white space preceding the first and
893 following the last character in the ruby text. That amount of white
894 space is normally equal to half the amount of inter-character space of
895 the ruby text. If the width of the ruby text is at least the width of
896 the base, then the same type of space distribution applies to the base.
897 In other words, if the base is shorter than the ruby text, the base is
898 distribute-space aligned. This type of alignment
899 is described by [[JLREQ]].
901 <div class="figure">
902 <p><img width="145" height="91"
903 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is shorter than base"
904 src="images/ra-ds.gif" /><img width="145" height="91"
905 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is longer than base"
906 src="images/ra-ds-rb.gif" /></p>
907 <p><b>Figure 4.2.7</b>: Distribute-space ruby alignment</p>
908 </div>
909 </dd>
911 <!--
912 <dt><strong>line-edge</strong></dt>
913 <dd>If the ruby text is not adjacent to a line edge, it is aligned as in
914 'auto'. If it is adjacent to a line edge, then it is still aligned as in
915 auto, but the side of the ruby text that touches the end of the line is
916 lined up with the corresponding edge of the base. This type of alignment
917 is described by [[JLREQ]]. This type of alignment is
918 relevant only to the scenario where the ruby text is longer than the
919 ruby base. In the other scenarios, this is just 'auto'.
920 <div class="figure">
921 <p><img class="example" width="146" height="109"
922 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base"
923 src="images/ra-le-l.gif" /><img class="example" width="146"
924 height="110"
925 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base"
926 src="images/ra-le-r.gif" /></p>
927 <p><b>Figure 4.2.8</b>: Line edge ruby alignment</p>
928 </div>
929 </dd>
930 -->
931 </dl>
933 <p>For a complex ruby with spanning elements, one additional consideration is
934 required. If the spanning element spans multiple 'rows' (other rbc or rtc
935 elements), and the ruby alignment requires space distribution among the
936 'spanned' elements, a ratio must be determined among the 'columns' of spanned
937 elements. This ratio is computed by taking into consideration the widest
938 element within each column.</p>
940 <h2 id="edge-effects">
941 Edge Effects</h2>
943 <h3 id="ruby-overhang">
944 Overhanging Ruby</h3>
946 <p>
947 When <i>ruby annotation box</i> is longer than its corresponding <i>ruby base box</i>,
948 the <i>ruby annotation box</i> may partially overhang adjacent boxes.
949 </p>
950 <p>
951 This level of the specification does not define
952 how much the overhang may be allowed, and under what conditions.
953 </p>
955 <p>If the ruby text is not allowed to overhang,
956 then the ruby behaves like a traditional inline box,
957 i.e. only its own contents are rendered within its boundaries
958 and adjacent elements do not cross the box boundary:
960 <div class="figure">
961 <p><img src="images/ro-n.gif"
962 alt="Diagram showing the ruby boxes interacting with adjacent text">
963 <p class="caption">Simple ruby whose text is not allowed to overhang adjacent text
964 </div>
966 <p>However, if <i>ruby annotation</i> content is allowed to overhang adjacent elements
967 and it happens to be wider than its base,
968 then the adjacent content is partially rendered within the area of the <i>ruby container box</i>,
969 while the <i>ruby annotation</i> may partially overlap the upper blank parts of the adjacent content:
971 <div class="figure">
972 <p><img src="images/ro-a.gif"
973 alt="Diagram showing the ruby boxes interacting with adjacent text">
974 <p class="caption">Simple ruby whose text is allowed to overhang adjacent text
975 </div>
977 <p>The <i>ruby annotations</i> related to a <i>ruby base</i>
978 must never overhang another <i>ruby base</i>.
980 <p>The alignment of the contents of the base or the ruby text
981 is not affected by overhanging behavior.
982 The alignment is achieved the same way regardless of the overhang behavior setting
983 and it is computed before the space available for overlap is determined.
984 It is controlled by the 'ruby-align' property.
986 <p>This entire logic applies the same way in vertical ideographic layout,
987 only the dimension in which it works in such a layout is vertical,
988 instead of horizontal.
990 <div class="example">
991 <p>
992 The user agent may use [[JIS4051]] recommendation of
993 using one ruby text character length as the maximum overhang length.
994 Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].
995 </p>
996 </div>
998 <h3 id="line-edge">
999 Line-edge Alignment</h3>
1001 <p>
1002 When a <i>ruby annotation box</i> that is longer than its <i>ruby base</i>
1003 is at the start or end edge of a line,
1004 the user agent <em>may</em> force the side of the <i>ruby annotation</i> that touches the edge of the line
1005 to align to the corresponding edge of the base.
1006 This type of alignment is described by [[JLREQ]].
1007 </p>
1008 <p>
1009 This level of the specification does not provide a mechanism to control this behavior.
1010 </p>
1011 <div class="figure">
1012 <p><img src="images/ra-le-l.gif"
1013 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base">
1014 <img src="images/ra-le-r.gif"
1015 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base">
1016 <p class="caption">Line-edge alignment
1017 </div>
1019 <!--
1020 <h3 id="rubyover">
1021 Ruby overhanging: the 'ruby-overhang' property</h3>
1023 <table class="propdef">
1024 <tr>
1025 <th>Name:
1026 <td><dfn>ruby-overhang</dfn>
1027 <tr>
1028 <th>Value:
1029 <td>auto | start | end | none
1030 <tr>
1031 <th>Initial:
1032 <td>none
1033 <tr>
1034 <th>Applies to:
1035 <td>the parent of elements with display: ruby-text
1036 <tr>
1037 <th>Inherited:
1038 <td>yes
1039 <tr>
1040 <th>Percentages:
1041 <td>N/A
1042 <tr>
1043 <th>Media:
1044 <td>visual
1045 <tr>
1046 <th>Computed value:
1047 <td>specified value (except for initial and inherit)
1048 </table>
1050 <p>This property determines whether, and on which side, ruby text is allowed
1051 to partially overhang any adjacent text in addition to its own base, when the
1052 ruby text is wider than the ruby base. Note that ruby text is never allowed to
1053 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
1054 a maximum amount by which ruby text may overhang adjacent text. The user agent may use
1055 the [[JIS4051]] recommendation of using one ruby text character
1056 length as the maximum overhang length. Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].</p>
1058 <p>Possible values:</p>
1059 <dl>
1060 <dt><strong>auto</strong></dt>
1061 <dd>The ruby text can overhang text adjacent to the base on either side. [[JLREQ]] and [[JIS4051]] specify the categories of characters that
1062 ruby text can overhang. The user agent is free to follow those recommendations or specify its own classes of
1063 characters to overhang. This is the initial value.
1064 <div class="figure">
1065 <p><img class="example" width="177" height="91"
1066 alt="Diagram of glyph layout in overhanging ruby" src="images/ro-a.gif" /></p>
1067 <p><b>Figure 4.3.1</b>: Ruby overhanging adjacent text</p>
1068 </div>
1069 </dd>
1070 <dt><strong>start</strong></dt>
1071 <dd>The ruby text can only overhang the text that precedes it. That means, for
1072 example, that ruby cannot overhang text that is to the right of it in
1073 horizontal LTR layout, and it cannot overhang text that is below it in
1074 vertical-ideographic layout.
1075 <div class="figure">
1076 <p><img class="example" width="199" height="91"
1077 alt="Diagram of glyph layout when ruby overhangs the preceding glyphs only"
1078 src="images/ro-s.gif" /></p>
1079 <p><b>Figure 4.3.2</b>: Ruby overhanging preceding text only</p>
1080 </div>
1081 </dd>
1082 <dt><strong>end</strong></dt>
1083 <dd>The ruby text can only overhang the text that follows it. That means, for
1084 example, that ruby cannot overhang text that is to the left of it in
1085 horizontal LTR layout, and it cannot overhang text that is above it in
1086 vertical-ideographic layout.
1087 <div class="figure">
1088 <p><img class="example" width="198" height="91"
1089 alt="Diagram of glyph layout when ruby overhangs the following characters only"
1090 src="images/ro-e.gif" /></p>
1091 <p><b>Figure 4.3.3</b>: Ruby overhanging following text only</p>
1092 </div>
1093 </dd>
1094 <dt><strong>none</strong></dt>
1095 <dd>The ruby text cannot overhang any text adjacent to its base, only its
1096 own base.
1098 <div class="figure">
1099 <p><img class="example" width="220" height="91"
1100 alt="Diagram of glyph layout in non-overhanging ruby"
1101 src="images/ro-n.gif" /></p>
1102 <p><b>Figure 4.3.4</b>: Ruby not allowed to overhang adjacent text</p>
1103 </div>
1104 </dd>
1105 </dl>
1107 <h3 id="rubyspan">
1108 Ruby annotation spanning: the 'ruby-span' property</h3>
1110 <table class="propdef">
1111 <tr>
1112 <th>Name:
1113 <td><dfn>ruby-span</dfn>
1114 <tr>
1115 <th>Value:
1116 <td>attr(x) | none
1117 <tr>
1118 <th>Initial:
1119 <td>none
1120 <tr>
1121 <th>Applies to:
1122 <td>elements with display: ruby-text
1123 <tr>
1124 <th>Inherited:
1125 <td>no
1126 <tr>
1127 <th>Percentages:
1128 <td>N/A
1129 <tr>
1130 <th>Media:
1131 <td>visual
1132 <tr>
1133 <th>Computed value:
1134 <td><number>
1135 </table>
1137 <p>This property controls the spanning behavior of annotation elements. </p>
1139 <p class="note"><span class="note-label">Note:</span> A XHTML user agent may also use the <samp>rbspan</samp>
1140 attribute to get the same effect.</p>
1142 <p>Possible values:</p>
1144 <dl>
1145 <dt><strong>attr(x)</strong></dt>
1146 <dd>The value of attribute 'x' as a string value. The string value is
1147 evaluated as a <number> to determine the number of ruby base elements to be
1148 spanned by the annotation element. If the <number> is '0', it is replaced by
1149 '1'.The <number> is the computed value. </dd>
1150 <dt>none</dt>
1151 <dd>No spanning. The computed value is '1'.</dd>
1152 </dl>
1154 <p>The following example shows an XML example using the 'display' property
1155 values associated with the 'ruby structure and the 'ruby-span' property</p>
1156 <pre class="xml">myruby { display: ruby; }
1157 myrbc { display: ruby-base-container; }
1158 myrb { display: ruby-base; }
1159 myrtc.before { display: ruby-text-container; ruby-position: before}
1160 myrtc.after { display: ruby-text-container; ruby-position: after}
1161 myrt { display: ruby-text; ruby-span: attr(rbspan); }
1162 ...
1163 <myruby>
1164 <myrbc>
1165 <myrb>10</myrb>
1166 <myrb>31</myrb>
1167 <myrb>2002</myrb>
1168 </myrbc>
1169 <myrtc class="before">
1170 <myrt>Month</myrt>
1171 <myrt>Day</myrt>
1172 <myrt>Year</myrt>
1173 </myrtc>
1174 <myrtc class="after">
1175 <myrt rbspan="3">Expiration Date</myrt>
1176 </myrtc>
1177 </myruby></pre>
1178 -->
1180 <h2 id="default-stylesheet" class="no-num">
1181 Appendix A: Default Style Sheet</h2>
1183 <p><em>This section is informative.</em>
1185 <h3 id="default-ua-ruby" class="no-num">
1186 <span class="secno">A.1</span> Supporting Ruby Layout</h3>
1188 <p>The following represents a default UA style sheet
1189 for rendering HTML and XHTML ruby markup as ruby layout:
1191 <pre>
1192 <!-- -->ruby { display: ruby; }
1193 <!-- -->rb { display: ruby-base; white-space: nowrap; }
1194 <!-- -->rt { display: ruby-text; white-space: nowrap; font-size: 50%; }
1195 <!-- -->rbc { display: ruby-base-container; }
1196 <!-- -->rtc { display: ruby-text-container; }</pre>
1198 <p>Additional rules for UAs supporting the relevant features of [[CSS3-TEXT-DECOR]] and [[CSS3-FONTS]]:
1199 <pre>rt { font-variant-east-asian: ruby; text-emphasis: none; }</pre>
1201 <p class="note">Authors should not use the above rules;
1202 a UA that supports ruby layout should provide these by default.
1204 <h3 id="default-inline" class="no-num">
1205 <span class="secno">A.2</span> Inlining Ruby Annotations</h3>
1207 <p>The following represents a sample style sheet
1208 for rendering HTML and XHTML ruby markup as inline annotations:
1210 <pre>ruby, rb, rt, rbc, rtc, rp {
1211 <!-- --> display: inline; white-space: inherit;
1212 <!-- --> font-variant-east-asian: inherit; text-emphasis: inherit; }</pre>
1214 <h3 id="default-parens" class="no-num">
1215 <span class="secno">A.3</span> Generating Parentheses</h3>
1217 <p>Unfortunately, because Selectors cannot match against text nodes,
1218 it's not possible with CSS to express rules that will automatically and correctly
1219 add parentheses to unparenthesized ruby annotations in HTML.
1220 (This is because HTML ruby allows implying the <i>ruby base</i> from raw text, without a corresponding element.)
1221 However, these rules will handle cases where either <code><rb></code>
1222 or <code><rtc></code> is used rigorously.
1224 <pre>
1225 <!-- -->/* Parens around <rtc> */
1226 <!-- -->rtc::before { content: "("; }
1227 <!-- -->rtc::after { content: ")"; }
1229 <!-- -->/* Parens before first <rt> not inside <rtc> */
1230 <!-- -->rb + rt::before,
1231 <!-- -->rtc + rt::before { content: "("; }
1233 <!-- -->/* Parens after <rt> not inside <rtc> */
1234 <!-- -->rb ~ rt:last-child::after,
1235 <!-- -->rt + rb::before { content: ")"; }
1236 <!-- -->rt + rtc::before { content: ")("; }</pre>
1238 <h2 id="glossary">
1239 Glossary</h2>
1240 <dl>
1241 <dt><a id="g-bopomofo"><strong><span
1242 lang="zh">Bopomofo</span></strong></a></dt>
1243 <dd>37 characters and 4 tone markings used as phonetics in Chinese,
1244 especially standard Mandarin.</dd>
1245 <dt><a id="g-hanja"><strong><span
1246 lang="ko">Hanja</span></strong></a></dt>
1247 <dd>Subset of the Korean writing system that utilizes ideographic
1248 characters borrowed or adapted from the Chinese writing system. Also see
1249 <a href="#g-kanji"><span lang="ja">Kanji</span></a>.</dd>
1250 <dt><a id="g-hiragana"><strong><span
1251 lang="ja">Hiragana</span></strong></a></dt>
1252 <dd>Japanese syllabic script, or character of that script. Rounded and
1253 cursive in appearance. Subset of the Japanese writing system, used together
1254 with kanji and katakana. In recent times, mostly used to write Japanese
1255 words when kanji are not available or appropriate, and word endings and
1256 particles. Also see <a
1257 href="#g-katakana"><span lang="ja">Katakana</span></a>.</dd>
1258 <dt><a id="g-ideogram"><strong>Ideograph</strong></a></dt>
1259 <dd>A character that is used to represent an idea, word, or word component,
1260 in contrast to a character from an alphabetic or syllabic script. The most
1261 well-known ideographic script is used (with some variation) in East Asia
1262 (China, Japan, Korea,...).</dd>
1263 <dt><a id="g-kana"><strong><span lang="ja">Kana</span></strong></a></dt>
1264 <dd>Collective term for hiragana and katakana.</dd>
1265 <dt><a id="g-kanji"><strong>Kanji</strong></a></dt>
1266 <dd>Japanese term for ideographs; ideographs used in Japanese. Subset of the
1267 Japanese writing system, used together with hiragana and katakana. Also see <a
1268 href="#g-hanja"><span lang="ko">Hanja</span></a>.</dd>
1269 <dt><a id="g-katakana"><strong><span
1270 lang="ja">Katakana</span></strong></a></dt>
1271 <dd>Japanese syllabic script, or character of that script. Angular in
1272 appearance. Subset of the Japanese writing system, used together with
1273 kanji and hiragana. In recent times, mainly used to write foreign words. Also see <a
1274 href="#g-hiragana"><span lang="ja">Hiragana</span></a>.</dd>
1275 <dt><a id="g-monoruby" name="g-monoruby"><strong>Mono-ruby</strong></a></dt>
1276 <dd>In Japanese typography: Ruby associated with a single character of
1277 the base text.</dd>
1278 <dt><a id="g-ruby"><strong>Ruby</strong></a></dt>
1279 <dd>A run of text that appears in the vicinity of another run of text and
1280 serves as an annotation or a pronunciation guide for that text.</dd>
1281 </dl>
1283 <h2 id="conformance">
1284 Conformance</h2>
1286 <h3 id="conventions">
1287 Document conventions</h3>
1289 <p>Conformance requirements are expressed with a combination of
1290 descriptive assertions and RFC 2119 terminology. The key words “MUST”,
1291 “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
1292 “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
1293 document are to be interpreted as described in RFC 2119.
1294 However, for readability, these words do not appear in all uppercase
1295 letters in this specification.
1297 <p>All of the text of this specification is normative except sections
1298 explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
1300 <p>Examples in this specification are introduced with the words “for example”
1301 or are set apart from the normative text with <code>class="example"</code>,
1302 like this:
1304 <div class="example">
1305 <p>This is an example of an informative example.</p>
1306 </div>
1308 <p>Informative notes begin with the word “Note” and are set apart from the
1309 normative text with <code>class="note"</code>, like this:
1311 <p class="note">Note, this is an informative note.</p>
1313 <h3 id="conformance-classes">
1314 Conformance classes</h3>
1316 <p>Conformance to CSS Ruby Module
1317 is defined for three conformance classes:
1318 <dl>
1319 <dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
1320 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
1321 style sheet</a>.
1322 <dt><dfn>renderer</dfn></dt>
1323 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1324 that interprets the semantics of a style sheet and renders
1325 documents that use them.
1326 <dt><dfn id="authoring-tool">authoring tool</dfn></dt>
1327 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1328 that writes a style sheet.
1329 </dl>
1331 <p>A style sheet is conformant to CSS Ruby Module
1332 if all of its statements that use syntax defined in this module are valid
1333 according to the generic CSS grammar and the individual grammars of each
1334 feature defined in this module.
1336 <p>A renderer is conformant to CSS Ruby Module
1337 if, in addition to interpreting the style sheet as defined by the
1338 appropriate specifications, it supports all the features defined
1339 by CSS Ruby Module by parsing them correctly
1340 and rendering the document accordingly. However, the inability of a
1341 UA to correctly render a document due to limitations of the device
1342 does not make the UA non-conformant. (For example, a UA is not
1343 required to render color on a monochrome monitor.)
1345 <p>An authoring tool is conformant to CSS Ruby Module
1346 if it writes style sheets that are syntactically correct according to the
1347 generic CSS grammar and the individual grammars of each feature in
1348 this module, and meet all other conformance requirements of style sheets
1349 as described in this module.
1351 <h3 id="partial">
1352 Partial implementations</h3>
1354 <p>So that authors can exploit the forward-compatible parsing rules to
1355 assign fallback values, CSS renderers <strong>must</strong>
1356 treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
1357 as appropriate</a>) any at-rules, properties, property values, keywords,
1358 and other syntactic constructs for which they have no usable level of
1359 support. In particular, user agents <strong>must not</strong> selectively
1360 ignore unsupported component values and honor supported values in a single
1361 multi-value property declaration: if any value is considered invalid
1362 (as unsupported values must be), CSS requires that the entire declaration
1363 be ignored.</p>
1365 <h3 id="experimental">
1366 Experimental implementations</h3>
1368 <p>To avoid clashes with future CSS features, the CSS2.1 specification
1369 reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
1370 syntax</a> for proprietary and experimental extensions to CSS.
1372 <p>Prior to a specification reaching the Candidate Recommendation stage
1373 in the W3C process, all implementations of a CSS feature are considered
1374 experimental. The CSS Working Group recommends that implementations
1375 use a vendor-prefixed syntax for such features, including those in
1376 W3C Working Drafts. This avoids incompatibilities with future changes
1377 in the draft.
1378 </p>
1380 <h3 id="testing">
1381 Non-experimental implementations</h3>
1383 <p>Once a specification reaches the Candidate Recommendation stage,
1384 non-experimental implementations are possible, and implementors should
1385 release an unprefixed implementation of any CR-level feature they
1386 can demonstrate to be correctly implemented according to spec.
1388 <p>To establish and maintain the interoperability of CSS across
1389 implementations, the CSS Working Group requests that non-experimental
1390 CSS renderers submit an implementation report (and, if necessary, the
1391 testcases used for that implementation report) to the W3C before
1392 releasing an unprefixed implementation of any CSS features. Testcases
1393 submitted to W3C are subject to review and correction by the CSS
1394 Working Group.
1396 <p>Further information on submitting testcases and implementation reports
1397 can be found from on the CSS Working Group's website at
1398 <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
1399 Questions should be directed to the
1400 <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
1401 mailing list.
1403 <h2 class=no-num id="acknowledgments">
1404 Acknowledgments</h2>
1406 <p>This specification would not have been possible without the help from:</p>
1408 <p>Stephen Deach, Martin Dürst, Hideki Hiura(<span lang="ja">樋浦 秀樹</span>), Masayasu Ishikawa(<span lang="ja">石川
1409 雅康</span>), Chris
1410 Pratley, Takao Suzuki(<span lang="ja">鈴木 孝雄</span>), Frank Yung-Fong Tang, Chris Thrasher, Masafumi Yabe<span lang="ja">家辺
1411 勝文</span>), Steve Zilles.</p>
1413 <h2 class="no-num" id="changes">
1414 Changes</h2>
1416 <p>The following major changes have been made since the previous Working Draft:
1417 <dl>
1418 <dt>Remove 'ruby-span' and mentions of <code>rbspan</code>.
1419 <dd>
1420 Explicit spanning is not used in HTML ruby in favor of implicit spanning.
1421 This can't handle some pathological double-sided spanning cases,
1422 but there seems to be no requirement for these at the moment.
1423 (For implementations that support full complex XHTML Ruby,
1424 they can imply spanning from the markup the same magic way
1425 that we handle cell spanning from tables. It doesn't seem
1426 necessary to include controls this in Level 1.)
1428 <dt>Defer 'ruby-overhang' and ''ruby-align: line-end'' to Level 2.
1429 <dd>
1430 It's somewhat complicated, advanced feature.
1431 Proposal is to make this behavior UA-defined
1432 and provide some examples of acceptable options.
1434 <dt>Close issue requesting 'display: rp': use ''display: none''.
1435 <dd>
1436 The i18nwg added an issue requesting a display value for <rp> elements.
1437 They're supposed to be hidden when &tl;ruby> is displayed as ruby.
1438 But this is easily accomplished already with ''display: none''.
1440 <dt>Change 'ruby-position' values to match 'text-emphasis-position'.
1441 <dd>
1442 Other than ''inter-character'', which we need to keep,
1443 it makes more sense to align ruby positions with 'text-emphasis-position',
1444 which can correctly handle various combinations of horizontal/vertical preferences.
1446 <dt>Remove unused values of 'ruby-align'.
1447 <dd>
1448 'left', 'right', and 'end' are not needed.
1450 <dt>Added 'ruby-merge' property to control jukugo rendering.
1451 <dd>
1452 This is a stylistic effect, not a structural one;
1453 the previous model assumed that it was structural and suggested handling it by changing markup. :(
1455 <dt>Remove ''inline'' from 'ruby-position'.
1456 <dd>
1457 This is do-able via ''display: inline'' on all the ruby-related elements,
1458 see <a href="#default-inline">Appendix A</a>
1460 <dt>Added <a href="#default-style">Default Style</a> rules
1461 <dd>
1462 As requested by i18nwg.
1464 <dt>Wrote anonymous box generation rules
1465 <dd>
1466 And defined pairing of bases and annotations.
1467 Should now handle all the crazy proposed permutations of HTML ruby markup.
1468 </dl>
1470 <h2 class=no-num id="references">
1471 References</h2>
1473 <h3 class="no-num" id="normative-references">
1474 Normative references</h3>
1475 <!--normative-->
1477 <h3 class="no-num" id="other-references">
1478 Other references</h3>
1479 <!--informative-->
1481 <h2 class="no-num" id="index">
1482 Index</h2>
1483 <!--index-->
1485 <h2 class="no-num" id="property-index">
1486 Property index</h2>
1487 <!-- properties -->
1489 </body>
1490 </html>
1491 <!-- Keep this comment at the end of the file
1492 Local variables:
1493 mode: sgml
1494 sgml-declaration:"~/SGML/HTML4.decl"
1495 sgml-default-doctype-name:"html"
1496 sgml-minimize-attributes:t
1497 sgml-nofill-elements:("pre" "style" "br")
1498 sgml-live-element-indicator:t
1499 sgml-omittag:nil
1500 sgml-shorttag:nil
1501 sgml-namecase-general:t
1502 sgml-general-insert-case:lower
1503 sgml-always-quote-attributes:t
1504 sgml-indent-step:nil
1505 sgml-indent-data:t
1506 sgml-parent-document:nil
1507 sgml-exposed-tags:nil
1508 sgml-local-catalogs:nil
1509 sgml-local-ecat-files:nil
1510 End:
1511 -->