Wed, 19 Jun 2013 00:42:16 +0900
[css-ruby] fix description for ruby-merge:collapse
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title>CSS Ruby Module Level 1</title>
6 <link rel=contents href="#contents">
7 <link rel=index href="#index">
8 <link rel="stylesheet" type="text/css" href="../default.css">
9 <link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
10 <link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
11 </head>
13 <body class="h-entry">
15 <div class="head">
16 <!--logo-->
18 <h1 class="p-name">CSS Ruby Module Level 1</h1>
20 <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>
21 <dl>
22 <dt>This version:
23 <dd><a class="u-url" href="[VERSION]">[VERSION]</a>
25 <dt>Latest version:
26 <dd><a href="http://www.w3.org/TR/[SHORTNAME]/">http://www.w3.org/TR/css3-ruby/</a>
28 <dt>Editor's draft:
29 <dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
30 (<a href="https://dvcs.w3.org/hg/csswg/log/tip/[SHORTNAME]/Overview.src.html">change log</a>)
32 <dt>Previous version:
33 <dd><a href="http://www.w3.org/TR/2011/WD-css3-ruby-20110630/">
34 http://www.w3.org/TR/2011/WD-css3-ruby-20110630/</a>
36 <dt>Issue Tracking:</dt>
37 <dd><a rel="issues" href="http://www.w3.org/Style/CSS/Tracker/products/FIXME">http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
39 <dt>Feedback:</dt>
40 <dd><a href="mailto:www-style@w3.org?subject=%5BSHORTNAME%5D%20feedback"
41 >www-style@w3.org</a>
42 with subject line “<kbd>[[SHORTNAME]]
43 <var>… message topic …</var></kbd>”
44 (<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/"
45 >archives</a>)
47 <dt>Editors:
48 <dd class="p-author h-card vcard">
49 <a class="p-name fn u-url url" rel="author"
50 href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a>,
51 <a class="p-org org h-org" href="http://www.mozilla.org/">Mozilla</a>
52 <dd class="p-author h-card vcard">
53 <a class="p-name fn u-url url" rel="author"
54 href="mailto:koji.a.ishii@mail.rakuten.com">Koji Ishii</a>,
55 <span class="p-org org">Rakuten, Inc.</span>
56 <dd class="p-author h-card vcard">
57 <a class="p-name fn u-url url" rel="author"
58 href="mailto:ishida@w3.org">Richard Ishida</a>,
59 <span class="p-org org">W3C</span>
61 <dt>Former editors:
62 <dd>Michel Suignard, Microsoft
63 <dd>Marcin Sawicki, Microsoft
64 </dl>
66 <!--copyright-->
68 <hr title="Separator for header">
69 </div>
71 <h2 class="no-num no-toc" id="abstract">Abstract</h2>
73 <p>
74 <span class="p-summary">
75 “Ruby” are short runs of text alongside the base text,
76 typically used in East Asian documents to indicate pronunciation
77 or to provide a short annotation.
78 This module describes the rendering model and formatting controls
79 related to displaying ruby annotations in CSS.
80 </span>
82 <a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing
83 the rendering of structured documents (such as HTML and XML) on screen, on
84 paper, in speech, etc.
86 <h2 class="no-num no-toc" id="status">Status of this document</h2>
88 <!--status-->
90 <p>The following features are at risk: …
92 <h2 class="no-num no-toc" id="contents">
93 Table of Contents</h2>
95 <!--toc-->
97 <h2 id="intro">
98 Introduction</h2>
100 <p><em>This section is not normative.</em>
102 <h3 id="placement">
103 Module interactions</h3>
105 <p>This module extends the inline box model of CSS Level 2 [[!CSS21]]
106 to support ruby.
108 <p>None of the properties in this module apply to the <code>::first-line</code> or
109 <code>::first-letter</code> pseudo-elements.
111 <h3 id="values">
112 Values</h3>
114 <p>This specification follows the
115 <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
116 definition conventions</a> from [[!CSS21]]. Value types not defined in
117 this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
118 Other CSS modules may expand the definitions of these value types: for
119 example [[CSS3VAL]], when combined with this module, expands the
120 definition of the <var><length></var> value type as used in this specification.</p>
122 <p>In addition to the property-specific values listed in their definitions,
123 all properties defined in this specification also accept the
124 <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
125 keyword as their property value. For readability it has not been repeated
126 explicitly.
128 <h3 id="conventions">
129 Document conventions</h3>
131 <p>Many typographical conventions in East Asian typography depend
132 on whether the character rendered is wide (CJK) or narrow (non-CJK).
133 There are a number of illustrations in this document
134 for which the following legend is used:
136 <dl>
137 <dt><img alt="Symbolic wide-cell glyph representation" width="39" height="39" src="images/fullwidth.gif">
138 <dd>Wide-cell glyph (e.g. Han) that is the <var>n</var>th character in the text run.
139 They are typically sized to 50% when used as annotations.
140 <dt><img alt="Symbolic narrow-cell glyph representation" width="19" height="39" src="images/halfwidth.gif">
141 <dd>Narrow-cell glyph (e.g. Roman) which is the <var>n</var>th glyph in the text run.
143 <p>The orientation which the above symbols assume in the diagrams
144 corresponds to the orientation that the glyphs they represent
145 are intended to assume when rendered by the user agent.
146 Spacing between these characters in the diagrams is incidental,
147 unless intentionally changed to make a point.
149 <h3 id="ruby-def">
150 What is ruby?</h3>
152 <p><dfn>Ruby</dfn> is the commonly-used name for a run of text
153 that appears alongside another run of text (referred to as the “base”)
154 and serves as an annotation or a pronunciation guide associated with that run of text.
156 <p>The following figures show two examples of Ruby,
157 a simple case and one with more complicated structure.
159 <div class="example">
160 <p>In this first example, a single annotation is used to annotate the base text.
161 <div class="figure">
162 <p><img src="images/licence.png"
163 alt="Example of ruby applied on top of a Japanese expression">
164 <p class="caption">Example of ruby used in Japanese (simple case)
165 </div>
166 <p>In Japanese typography, this case is sometimes called
167 <i lang="ja">taigo</i> ruby or group-ruby (per-word ruby),
168 because the annotation as a whole is associated
169 with multi-character word (as a whole).
170 </div>
172 <div class="example">
173 <p>In this second example,
174 two levels of annotations are attached to a base sequence:
175 the hiragana characters on top refer to the pronunciation of each of the base kanji characters,
176 while the words “Keio” and “University” on the bottom are annotations describing the English translation.
177 <div class="figure">
178 <p><img src="images/ruby-univ.gif"
179 alt="Example showing complex ruby with annotation text over and under the base characters">
180 <p class="caption">Complex ruby with annotation text over and under the base characters
181 </div>
182 <p>
183 <p>Notice that to allow correct association between the hiragana characters and
184 their corresponding Kanji base characters,
185 the spacing between these Kanji characters is adjusted.
186 (This happens around the fourth Kanji character in the figure above.)
187 To avoid variable spacing between the Kanji characters in the example above
188 the hiragana annotations can be styled as a <i>collapsed annotation</i>,
189 which will look more like the group-ruby example earlier.
190 However because the base-annotation pairings are recorded in the ruby structure,
191 if the text breaks across lines, the annotation characters will stay
192 correctly paired with their respective base characters.
193 </div>
195 <i>Ruby</i> formatting as used in Japanese is described in JIS X-4051 [[JIS4051]] (in Japanese)
196 and in Requirements for Japanese Text Layout [[JLREQ]] (in English and Japanese)].
197 In HTML, ruby structure and markup to represent it is described
198 in the Ruby Markup Extension specification.
199 This module describes the CSS rendering model
200 and formatting controls relevant to ruby layout of such markup.
202 <h2 id="ruby-model">
203 Ruby Formatting Model</h2>
205 <p>The CSS ruby model is based on
206 the <a href="http://darobin.github.io/html-ruby/">HTML Ruby Markup Extension</a>
207 and <a href="http://www.w3.org/TR/ruby/">XHTML Ruby Annotation Recommendation</a> [[RUBY]].
208 In this model, a ruby structure consists of
209 one or more <dfn>ruby base</dfn> elements representing the base (annotated) text,
210 associated with one or more levels of <dfn>ruby annotation</dfn> elements representing the annotations.
211 The structure of ruby is similar to that of a table:
212 there are “rows” (the base text level, each annotation level)
213 and “columns” (each <i>ruby base</i> and its corresponding <i>ruby annotations</i>).
215 <p>Consecutive bases and annotations are grouped together into <dfn>ruby segments</dfn>.
216 Within a <i>ruby segment</i>, a <i>ruby annotation</i> may span multiple <i>ruby bases<i>.
218 <p class="note">In HTML, a single <code><ruby></code> element may contain multiple <i>ruby segments</i>.
219 (In the XHTML Ruby model, a single <code><ruby></code> element can only contain one <i>ruby segment</i>.)
221 <h3 id="ruby-display">
222 Ruby-specific 'display' property values</h3>
224 <p>For document languages (such as XML applications) that do not have pre-defined ruby elements,
225 authors must map document language elements to ruby elements;
226 this is done with the 'display' property.
228 <table class="propdef">
229 <tr>
230 <th>Name:
231 <td>display
232 <tr>
233 <th><a href="#values">New Values</a>:
234 <td>ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container
235 </table>
237 <p>The following new 'display' values assign ruby layout roles to an arbitrary element:
239 <dl>
240 <dt>''ruby''
241 <dd>Specifies that an element generates a <dfn title="ruby container | ruby container box">ruby container box</dfn>.
242 (Corresponds to HTML/XHTML <code><ruby></code> elements.)
243 <dt>''ruby-base''
244 <dd>Specifies that an element generates a <dfn title="ruby base box | ruby base">ruby base box</dfn>.
245 (Corresponds to HTML/XHTML <code><rb></code> elements.)
246 <dt>''ruby-text''
247 <dd>Specifies that an element generates a <dfn title="ruby annotation box | ruby annotation">ruby annotation box</dfn>.
248 (Corresponds to HTML/XHTML <code><rt></code> elements.)
249 <dt>''ruby-base-container''
250 <dd>Specifies that an element generates a <dfn title="ruby base container box | ruby base container">ruby base container box</dfn>.
251 (Corresponds to XHTML <code><rbc></code> elements; always implied in HTML.)
252 <dt>''ruby-text-container''
253 <dd>Specifies that an element generates a <dfn title="ruby annotation container box | ruby annotation container">ruby annotation container box</dfn>.
254 (Corresponds to HTML/XHTML <code><ruby></code> elements.)
255 </dl>
257 <h3 id="box-fixup">
258 Anonymous Ruby Box Generation</h3>
260 <p>The CSS model does not require that the document language
261 include elements that correspond to each of these components.
262 Missing parts of the structure are implied through the anonymous box generation rules
263 <a href="http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes">similar to those used to normalize tables</a>. [[!CSS21]]
265 <ol>
266 <li>Any in-flow block-level boxes directly contained by a
267 <i>ruby container</i>,
268 <i>ruby base container</i>,
269 <i>ruby annotation container</i>,
270 <i>ruby base box</i>,
271 or <i>ruby annotation box</i>
272 are forced to be inline-level boxes,
273 and their 'display' value computed accordingly.
274 For example,
275 the 'display' property of an in-flow element with ''display: block''
276 parented by an element with ''display: ruby-text''
277 computes to ''inline-block''.
278 This computation occurs after any intermediary anonymous-box fixup
279 (such as that required by internal table elements).
281 <li>Any consecutive sequence of <i>ruby bases</i> not parented by a <i>ruby base container</i>
282 is wrapped in an anonymous <i>ruby base container</i>.
283 Similarly, any consecutive sequence of <i>ruby annotations</i> not parented by a <i>ruby annotation container</i>
284 is wrapped in an anonymous <i>ruby annotation container</i>.
286 <li>Within each <i>ruby base container</i>,
287 each sequence of inline-level boxes is wrapped in an anonymous <i>ruby base box</i>.
288 Similarly, within each <i>ruby annotation container</i>,
289 each sequence of inline-level boxes is wrapped in an anonymous <i>ruby annotation box</i>.
291 <li>A sequence of <i>ruby base containers</i> and/or <i>ruby annotation containers</i>
292 not parented by a <i>ruby container</i>
293 is wrapped in an anonymous <i>ruby container</i>.
294 </ol>
296 <p>At this point, all ruby layout structures are properly parented,
297 and the UA can start to associate bases with their annotations.
299 <p class="note">
300 Note that the UA is not required to create any of these anonymous boxes in its internal structures,
301 as long as pairing and layout behaves as if they existed.
303 <h3 id="pairing">
304 Ruby Pairing and Annotation Levels</h3>
306 <p>Within a ruby structure,
307 each <i>ruby bases</i> are associated with <i>ruby annotations</i>
308 and vice versa.
309 A <i>ruby base</i> can be associated with at most one <i>ruby annotation</i> per annotation level.
310 If there are multiple annotation levels, it can therefore be associated with multiple <i>ruby annotations</i>.
311 A <i>ruby annotation</i> is associated with one or more <i>ruby bases</i>;
312 annotations can span multiple bases.
314 <p><dfn>Annotation pairing</dfn> is the process of associating
315 <i>ruby annotations</i> with <i>ruby bases</i>.
317 <ol>
318 <li>
319 <p>First, the ruby structure is divided into <i>ruby segments</i>,
320 each consisting of a single <i>ruby base container</i>
321 followed by one or more <i>ruby annotation containers</i>.
322 If the first child of a <i>ruby container</i> is a <i>ruby annotation container</i>,
323 an anonymous, empty <i>ruby base container</i> is assumed to exist before it.
324 Similarly, if the <i>ruby container</i> contains consecutive <i>ruby base containers</i>,
325 anonymous, empty <i>ruby annotation containers</i> are assumed to exist between them.
326 The <i>ruby base container</i> in each segment is thus associated
327 with each of the <i>ruby annotation containers</i> in that segment.
329 <p>Each <i>ruby annotation containers</i> in a <i>ruby segment</i>
330 represents one <dfn title="annotation level | level">level</dfn> of annotation:
331 the first one represents the first level of annotation,
332 the second one represents the second level of annotation,
333 and so on.
335 <li>Within each <i>ruby segment</i>,
336 each <i>ruby base box</i> in the <i>ruby base container</i>
337 is paired with one <i>ruby annotation box</i>
338 from each <i>ruby annotation container</i> in its <i>ruby segment</i>.
339 If there are not enough <i>ruby annotations</i> in a <i>ruby annotation container</i>,
340 the last one is associated with any excess <i>ruby bases</i>.
341 (If there are not any in the <i>ruby annotation container</i>, an anonymous empty one is assumed to exist.)
342 If there are not enough <i>ruby bases</i>,
343 any remaining <i>ruby annotations</i> are assumed to be associated
344 with empty, anonymous bases inserted at the end of the <i>ruby base container</i>.
345 </ol>
347 <p>A this point, ruby “columns” are defined,
348 each represented by a single <i>ruby base</i>
349 and associated with one <i>ruby annotation</i> (possibly an empty, anonymous one)
350 from each <i>annotation level</i>.
352 <h4 id="nested-pairing">
353 Nested Ruby</h4>
355 <p>When <i>ruby containers</i> are nested,
356 pairing begins with the deepest <i>ruby container</i>,
357 then expands out,
358 treating each <i>ruby container</i> nested within another <i>ruby container</i>
359 as a <i>ruby base</i>,
360 and associating each <i>ruby annotation</i>
361 associated with the nested <i>ruby container</i>
362 as being associated with (spanning) all of its <i>ruby bases</i>.
364 <p>Using nested <i>ruby containers</i> thus allows the representation
365 of complex spanning relationships.
367 <p class="issue">This shouldn't belong in Level 1. But HTML5 allows it, so we have to handle it. Yay HTML5.
369 <h3 id="box-model">
370 Generating Ruby Structure</h3>
372 <p>
374 <h3 id="box-model">
375 Ruby box model</h3>
377 <p>In the following description, the elements specified by Ruby
378 Annotation [[RUBY]] are used to describe the box model. As mentioned
379 earlier, a user agent can obtain the same results by using the Ruby specific 'display'
380 property values. </p>
382 <p>For a user agent that supports the ruby markup, the ruby structure consists of three or more
383 boxes. The outermost container is the <a
384 href="http://www.w3.org/TR/ruby/#ruby"><samp>ruby</samp></a> element itself.
385 In the simple case, it is a container for two non-overlapping boxes: the ruby
386 text box (<a href="http://www.w3.org/TR/ruby/#rt"><samp>rt</samp></a> element)
387 and the ruby base box (<a
388 href="http://www.w3.org/TR/ruby/#rb"><samp>rb</samp></a> element). The
389 positioning of these two boxes relative to each other is controlled by the <a
390 href="#rubypos">'ruby-position'</a> property.</p>
392 <div class="figure">
393 <img class="example" width="223" height="93"
394 alt="Diagram of the ruby box model consisting of two boxes, one on top of the other, enclosed within a third box representing the ruby element"
395 src="images/r-box-t.gif" />
397 <p><b>Figure 3.2.1</b>: Ruby box model (simple case)</p>
398 </div>
400 <p>In the case of complex ruby, the ruby element is a container for two or
401 three non-overlapping boxes: one ruby base collection (<a
402 href="http://www.w3.org/TR/ruby/#rbc"><samp>rbc</samp></a> element), and one
403 or two ruby text collections (<a
404 href="http://www.w3.org/TR/ruby/#rtc"><samp>rtc</samp></a> element). The
405 <samp>rbc</samp> element is itself a container for one or several ruby base
406 box (<samp>rb</samp> element), while each <samp>rtc</samp> element is a
407 container for one or several ruby text box (rt element). The position of the
408 <samp>rtc</samp> element in relation to the related <samp>rbc</samp> element
409 is controlled by the <a href="#rubypos">'ruby-position'</a> property. The two
410 following figures show examples of these complex ruby.</p>
412 <div class="figure">
413 <img src="images/r-box-g.gif"
414 alt="Diagram of a group ruby with a full ruby text above and partial ruby text below" width="408" height="170" />
416 <p><b>Figure 3.2.2</b>: Ruby box model (complex ruby with an empty rt element
417 after)</p>
418 </div>
420 <p>In the example above, the ruby text after (below) the ruby bases contains two <samp>rt</samp> elements with the first one
421 being empty, the empty <samp>rt</samp> element corresponds to the first part
422 of the ruby base collection (the first part is identified by the first <samp>rb</samp> element
423 within the <samp> rbc</samp> element).</p>
425 <div class="figure">
426 <img src="images/r-box-h.gif"
427 alt="Diagram of a group ruby with a spanning ruby text above and partial ruby text below" width="400" height="173" />
429 <p><b>Figure 3.2.3</b>: Ruby box model (complex ruby with a spanning ruby text
430 element)</p>
431 </div>
433 <p>In the example above, the ruby text before (above) the ruby bases spans the whole ruby base collection. The
434 ruby text after (below) the ruby bases still contain two <samp>rt</samp> elements, one of
435 which is empty. The spanning behavior of <samp>rt</samp> text elements is
436 controlled by the <a
437 href="http://www.w3.org/TR/ruby/#ruby"><samp>rbspan</samp></a> attribute in a
438 way similar to the <samp>colspan</samp> attribute used for table column.</p>
440 <p class="issue"><span class="issuehead">Issue: </span> The examples above contain the term 'group ruby', which is not used elsewhere in this specification. It appears to be used in a way that is different to the use of the term in JLREQ. I propose to replace it with just 'ruby'.</p>
441 <p class="note"><span class="note-label">Note:</span> The visual description of the ruby elements does not refer
442 necessarily to the logical orders of the elements</p>
444 <p>The width of the ruby box is by default determined by its widest child
445 element, whose width in turn is determined by its content. The width of all direct
446 children of the <samp>ruby</samp> element is the width of the widest children. In this respect, the ruby
447 box is much like a two or three row <samp>table</samp> element, with the
448 following exceptions:</p>
449 <ul>
450 <li>the ruby box is an inline element, like an image, even though it itself,
451 like a table, is a container of other boxes</li>
452 <li>the equivalent of the cells: the <samp>rb</samp> element and the
453 <samp>rt</samp> text element can only contain inline-level elements.</li>
454 <li>the content of each 'cell' is always measured at its maximum width</li>
455 <li>unlike a table, a ruby element doesn't have to fit in a line, the ruby
456 box may be split into several boxes at line boundary, depending of the
457 spanning of the ruby texts. This is however only possible for the complex
458 ruby and can only happen at the boundary of non spanning elements.</li>
459 <li>both the ruby text and the ruby base boxes may overlap with adjacent
460 text (outside of the ruby element) if an appropriate <a
461 href="#rubyover">'ruby-overhang'</a> parameter is set via CSS. Note
462 however that the actual content of the ruby base cannot overlap with that
463 adjacent text. The distribution of the content of the ruby base within the
464 ruby base box is controlled by the <a href="#rubyalign">'ruby-align'</a>
465 property.</li>
466 </ul>
468 <p>If the ruby text is not allowed to overhang, then the ruby behaves like a
469 traditional box, i.e. only its contents are rendered within its boundaries and
470 adjacent elements do not cross the box boundary:</p>
472 <div class="figure">
473 <p><img class="example" width="220" height="91"
474 alt="Diagram showing the ruby boxes interacting with adjacent text"
475 src="images/ro-n.gif" /></p>
477 <p><b>Figure 3.2.4</b>: Simple ruby whose text is not allowed to overhang
478 adjacent text</p>
479 </div>
481 <p>However, if ruby text is allowed to overhang adjacent elements and it
482 happens to be wider than its base, then the adjacent content is partially
483 rendered within the area of the ruby base box, while the ruby text may be
484 partially overlapping with the upper blank parts of the adjacent content:</p>
486 <div class="figure">
487 <p><img class="example" width="177" height="91"
488 alt="Diagram showing the ruby boxes interacting with adjacent text"
489 src="images/ro-a.gif" /></p>
491 <p><b>Figure 3.2.5</b>: Simple ruby whose text is allowed to overhang adjacent
492 text</p>
493 </div>
495 <p>The ruby text related to a ruby base can never overhang another ruby
496 base.</p>
498 <p>The alignment of the contents of the base or the ruby text is not affected
499 by the overhanging behavior. The alignment is achieved the same way regardless
500 of the overhang behavior setting and it is computed before the space available
501 for overlap is determined. It is controlled by the <a
502 href="#rubyalign">'ruby-align'</a> property.</p>
504 <p>The exact circumstances in which the ruby text will overhang other
505 elements, and to what degree it will do so, will be controlled by the <a
506 href="#rubyover">'ruby-overhang'</a> property.</p>
508 <p>This entire logic applies the same way in vertical ideographic layout, only
509 the dimension in which it works in such a layout is vertical, instead of
510 horizontal.</p>
512 <p class="note"><span class="note-label">Note:</span> Because the purpose of the XHTML <samp>rp</samp> element
513 [[RUBY]] is to allow pre-existing user agents
514 to parenthesize ruby text content, an XHTML user agent should use a styling rule
515 for these elements that avoids rendering them such as <samp>rp {display:
516 none}</samp>.</p>
518 <h3 id="ruby-line-height">
519 Ruby box and line stacking</h3>
521 <p>The interaction of the ruby box and line stacking is controlled by the
522 'line-stacking-ruby' property described in the CSS3 Line Module. That property
523 takes two values: 'include-ruby' and 'exclude-ruby. Depending on the property
524 value, the ruby box is considered or excluded for line stacking. Even if the
525 ruby box is considered for line stacking, some values of the
526 'line-stacking-strategy' property (also described in the CSS3 Line module) can
527 still create occurrences where a the ruby box will eventually be ignored (e.g.
528 case where the 'line-stacking-strategy' value is 'block-line-height').</p>
530 <p>In the following figure, each line box is shown with leading space
531 distributed before and after the two text segments ('Previous line' and 'Ruby
532 base'); the dotted lines show the line box for each line. The
533 'line-stacking-ruby' property is set to 'exclude-ruby'. The achieved effect is
534 that the ruby box does not affect the line to line spacing. It is however the
535 responsibility of the style author to avoid 'bleeding' effects between the ruby
536 text and the surrounding text of images.</p>
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>
548 <p>In the following figure, the line boxes have no extra leading space. The
549 'line-stacking-ruby' property is set to 'include-ruby' and the
550 'line-stacking-strategy' property is set to a value where inline boxes are
551 considered for line stacking. In this case, the line box with
552 the ruby text is affected and has its 'stack-height' increased by the amount
553 necessary to fit the ruby text.</p>
555 <div class="figure">
556 <p>
557 <img class="example"
558 alt="Diagram showing the ruby text expanding above base text"
559 src="images/rlh-b.gif" width="210" height="111" /></p>
561 <p><b>Figure 3.3.2</b>: Ruby text increasing line height</p>
562 </div>
563 <p>This mechanism allows rendering of evenly spaced lines of text within a
564 block-level element, whether a line contains ruby or not. The authors need
565 only to set for the block-level element a line height value larger than the
566 computed line-height of the largest ruby element within the block.</p>
568 <h3 id="ruby-line-breaking">
569 Ruby box and line breaking</h3>
571 <p>When a ruby falls at the end of a line where there is not sufficient room for the entire ruby to fit on the line, the complex ruby may be broken at locations where boxes of the ruby container align. Some examples are provided below to provide more clarity.</p>
573 <p>
574 <img class="example"
575 alt="Diagram showing the line breaking opportunity in a complex ruby"
576 src="images/r-break-a.gif" width="408" height="201" /></p>
578 <p><b>Figure 3.4.1</b>: Complex ruby line breaking opportunity</p>
580 <p>
581 <img class="example"
582 alt='Diagram showing the line breaking opportunity in a "Bopomofo" ruby'
583 src="images/r-break-b.gif" width="300" height="90" /></p>
585 <p><b>Figure 3.4.1</b>: "Bopomofo" ruby line breaking opportunity</p>
586 <p class="issue"><span class="issuehead">Issue: </span> Line breaks should only be allowed within ruby if the ruby base text can be broken at that point. E.g. if complex Ruby is used to annotate the two morphemes of "butterfly", the fact that we have added ruby annotations should not cause a line breaking opportunity to be present between "butter" and "fly" </p>
587 <h2 id="ruby-props">
588 Ruby Properties</h2>
590 <h3 id="rubypos">
591 Ruby positioning: the 'ruby-position' property</h3>
593 <table class="propdef">
594 <tr>
595 <th>Name:
596 <td><dfn>ruby-position</dfn>
597 <tr>
598 <th><a href="#values">Value</a>:
599 <td>[ over | under | inter-character ] && [ right | left ]
600 <tr>
601 <th>Initial:
602 <td>over right
603 <tr>
604 <th>Applies to:
605 <td>the parent of elements with display: ruby-text.
606 <tr>
607 <th>Inherited:
608 <td>yes
609 <tr>
610 <th>Percentages:
611 <td>N/A
612 <tr>
613 <th>Media:
614 <td>visual
615 <tr>
616 <th>Computed value:
617 <td>specified value (except for initial and inherit)
618 <tr>
619 <th>Animatable:
620 <td>no
621 <tr>
622 <th>Canonical order:
623 <td><abbr title="follows order of property value definition">per grammar</abbr>
624 </table>
625 <p class="issue"><span class="issuehead">Issue: </span> We replaced 'right' with 'inter-character', since that was its original intended purpose and such removes potential ambiguity with 'inline' or 'before'. Bopomofo ruby needs special handling by the implementation, if ruby is to always appear to the right. (Note that the user may also choose to position bopomofo ruby before the base, in which case they would use the normal 'before' setting.)</p>
626 <p>This property is used by the parent of elements with display: ruby-text to
627 control the position of the ruby text with respect to its base. Such parents
628 are typically either the <samp>ruby</samp> element itself (simple ruby) or the
629 <samp>rtc</samp> element (complex ruby). This assures that all parts of a <samp>rtc</samp>
630 element will be displayed in the same position. Possible values:</p>
631 <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>
632 <dl>
633 <dt><dfn title="ruby-position:over">''over''</dfn></dt>
634 <dd>The ruby text appears over the base in horizontal text.
635 This is the most common setting used in ideographic East Asian writing systems.
636 This is the initial value.
638 <div class="figure">
639 <p>
640 <img
641 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing above the base"
642 src="images/shinkansen-top.gif" width="140" height="33" /></p>
643 <p><b>Figure 4.1.1</b>: Top ruby in horizontal layout applied to
644 Japanese text</p>
645 </div>
646 </dd>
648 <dt><dfn title="ruby-position:right">''right''</dfn></dt>
649 <dd>The ruby text appears on the right side of the base in vertical text.
651 <div class="figure">
652 <p>
653 <img
654 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the right of the base"
655 src="images/shinkansen-right.gif" width="33" height="141" /></p>
656 <p><b>Figure 4.1.2</b>: Top ruby in vertical ideographic layout applied
657 to Japanese text</p>
658 </div>
659 </dd>
661 <dt><dfn title="ruby-position:under">''under''</dfn></dt>
662 <dd>The ruby text appears under the base in horizontal text.
663 This is a relatively rare setting used in ideographic East Asian writing systems,
664 most easily found in educational text.
666 <div class="figure">
667 <p>
668 <img
669 alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing below the base"
670 src="images/shinkansen-bottom.gif" width="142" height="36" /></p>
671 <p><b>Figure 4.1.3</b>: Bottom ruby in horizontal layout applied to Japanese text</p>
672 </div>
673 </dd>
675 <dt><dfn title="ruby-position:left">''left''</dfn></dt>
676 <dd>The ruby text appears on the left side of the base in vertical text.
678 <div class="figure">
679 <p>
680 <img
681 alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the left of the base"
682 src="images/shinkansen-left.gif" width="37" height="141" /></p>
683 <p><b>Figure 4.1.4</b>: Bottom ruby in vertical ideographic layout applied to Japanese text</p>
684 </div>
685 </dd>
687 <dt><dfn title="ruby-position:inter-character">''inter-character''</dfn></dt>
688 <dd>
689 <p class="issue"><span class="issuehead">Issue: </span> We replaced 'right' with 'inter-character', since that was its original intended purpose and such removes potential ambiguity with 'inline' or 'before'. Bopomofo ruby needs special handling by the implementation, if ruby is to always appear to the right. (Note that the user may also choose to position bopomofo ruby before the base, in which case they would use the normal 'before' setting.) See <a href="http://www.w3.org/Search/Mail/Public/advanced_search?keywords=&hdr-1-name=subject&hdr-1-query=[CSS3+Ruby]%20Vertical+layout+not+enough+for+bopomofo&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> following a request from the i18n WG.</p>
690 <p>The ruby text appears on the right of the base in horizontal text.
692 <p>This value is provided for the special case of traditional Chinese as used especially in
693 Taiwan: ruby (made of <a href="#g-bopomofo"><span
694 lang="zh">bopomofo</span></a> glyphs) in that context appears vertically along
695 the right side of the base glyph,
696 even when the layout of the base characters is horizontal:</p>
698 <div class="figure">
699 <p><img alt="Example of Taiwanese-style ruby"
700 width="138" height="42" src="images/bopomofo.gif" /></p>
701 <p><b>Figure 4.1.5</b>: "<span lang="zh">Bopomofo</span>" ruby in
702 traditional Chinese (ruby text shown in blue for clarity) in horizontal
703 layout</p>
704 </div>
705 <p class="note"><span class="note-label">Note:</span> The bopomofo
706 transcription is written in the normal way as part of the ruby text.
707 The user agent is responsible for ensuring the correct relative alignment
708 and positioning of the glyphs, including those corresponding to the
709 tone marks, when displaying. Tone marks are spacing characters that occur in memory at the end of the ruby text for each base character. They are usually displayed in a separate column to the right of the bopomofo characters, and the height of the tone mark depends on the number of characters in the syllable. One tone mark, however, is placed above the bopomofo, not to the right of it.</p>
710 <p class="note"><span class="note-label">Note:</span> To make bopomofo annotations appear before or after the base text, like annotations for most other East Asian writing systems, use the 'before' and 'after' values of ruby-position.</p>
711 <p>It is not defined how a user-agent should handle ruby text that is not bopomofo
712 when the value of ruby-position is set to 'inter-character'.</p>
713 <!-- See Taiwanese requirements doc for EPUB at http://epub-revision.googlecode.com/files/EGLS_TW_eng.ppt -->
714 </dd>
716 <!--
717 <dt><strong>inline</strong></dt>
718 <dd>
719 <p>Ruby text follows the ruby base with no special styling. The value can be used to disable ruby text positioning.</p>
720 <p>If the author has used the XHTML <samp>rp</samp> element [[RUBY]] they should set the <samp>display</samp> value for that element to <samp>inline</samp>, so that the ruby text is distinguishable from the base text. If no <samp>rp</samp> element has been used, the author can use the <samp>content</samp> property with the <samp>:before</samp> and <samp>:after</samp> pseudo-elements to set off the ruby text. </p>
721 <p class="issue"><span class="issuehead">Issue: </span> Here is a <a href="http://www.w3.org/Search/Mail/Public/advanced_search?keywords=&hdr-1-name=subject&hdr-1-query=[CSS3+Ruby]%20inline+value+description+missing&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">request </a>for this section to be added, from the i18n WG..</p>
722 </dd>
723 -->
724 </dl>
726 <p>If two rtc elements are set with the same ruby-position value, (for example
727 both 'before'), the relative position of the two elements is undefined. This
728 setting should not be used.</p>
730 <h3 id="rubymerge">Ruby merge: the 'ruby-merge' property</h3>
732 <table class="propdef">
733 <tr>
734 <th>Name:
735 <td><dfn>ruby-merge</dfn>
736 <tr>
737 <th><a href="#values">Value</a>:
738 <td>separate | collapse | auto
739 <tr>
740 <th>Initial:
741 <td>separate
742 <tr>
743 <th>Applies to:
744 <td>all elements and generated content
745 <tr>
746 <th>Inherited:
747 <td>yes
748 <tr>
749 <th>Percentages:
750 <td>N/A
751 <tr>
752 <th>Media:
753 <td>visual
754 <tr>
755 <th>Computed value:
756 <td>specified value (except for initial and inherit)
757 </table>
759 <p>
760 This property controls how ruby annotation boxes should be rendered
761 when there are more than one in a ruby container box.
762 </p>
764 <p>Possible values:</p>
765 <dl>
766 <dt><dfn title="ruby-merge:separate">''separate''</dfn></dt>
767 <dd>
768 <p>
769 Each ruby annotation box is rendered in the same column as its corresponding base box.
770 This style is called Mono-ruby in [[JLREQ]].
771 </p>
773 <div class="example">
774 <p>The following two markups render the same:</p>
775 <pre><ruby>無<rt>む</ruby><ruby>常<rt>じょう</ruby></pre>
776 <p>and:</p>
777 <pre><ruby style="ruby-merge:separate"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
778 </div>
779 </dd>
781 <dt><dfn title="ruby-merge:collapse">''collapse''</dfn></dt>
782 <dd>
783 <p>
784 All ruby annotation boxes are concatenated,
785 and rendered to the concatenated ruby base boxes.
786 This style renders similar to Group-ruby in [[JLREQ]],
787 except that it allows line break between annotation pairs.
788 </p>
790 <div class="example">
791 <p>The following two markups render the same if fit in a line:</p>
792 <pre><ruby>無常<rt>むじょう</ruby></pre>
793 <p>and:</p>
794 <pre><ruby style="ruby-merge:collapse"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
795 </div>
796 </dd>
798 <dt><dfn title="ruby-merge:auto">''auto''</dfn></dt>
799 <dd>
800 <p>
801 The user agent may use any algorithm to determine how each ruby annotation box
802 is rendered to its corresponding base box.
803 </p>
804 <div class="example">
805 <p>
806 One possible algorithm is described as Jukugo-ruby in [[JLREQ]].
807 </p>
808 <p>
809 Another, more simplified algorithm of Jukugo-ruby is
810 to render as Mono-ruby if all ruby annotation boxes fit within
811 advances of their corresponding base boxes,
812 and render as Group-ruby otherwise.
813 </p>
814 </div>
815 </dd>
816 </dl>
818 <h3 id="rubyalign">
819 Ruby alignment: the 'ruby-align' property</h3>
821 <table class="propdef">
822 <tr>
823 <th>Name:
824 <td><dfn>ruby-align</dfn>
825 <tr>
826 <th><a href="#values">Value</a>:
827 <td>auto | start | center |
828 distribute-letter | distribute-space
829 <tr>
830 <th>Initial:
831 <td>auto
832 <tr>
833 <th>Applies to:
834 <td>all elements and generated content
835 <tr>
836 <th>Inherited:
837 <td>yes
838 <tr>
839 <th>Percentages:
840 <td>N/A
841 <tr>
842 <th>Media:
843 <td>visual
844 <tr>
845 <th>Computed value:
846 <td>specified value (except for initial and inherit)
847 </table>
849 <p>This property can be used on any element to control the text alignment of
850 the ruby text and ruby base contents relative to each other. It applies to all
851 the rubys in the element. For simple ruby, the alignment is applied to the
852 ruby child element whose content is shorter: either the <a
853 href="http://www.w3.org/TR/ruby/#rb"><samp>rb</samp></a> element or the <a
854 href="http://www.w3.org/TR/ruby/#rt"><samp>rt</samp></a> element [[RUBY]].
855 For complex ruby, the alignment is also applied to the
856 ruby child elements whose content is shorter: either the <samp>rb</samp>
857 element and/or one or two <samp>rt</samp> elements for each related ruby text
858 and ruby base element within the <samp>rtc</samp> and <samp>rbc</samp>
859 element.</p>
861 <p>Possible values:</p>
862 <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>
863 <dl>
864 <dt><dfn title="ruby-align:auto">''auto''</dfn></dt>
865 <dd>
866 <p>The user agent determines how the ruby contents are aligned.
867 This is the initial value.
868 The behavior recommended by [[JLREQ]] is for wide-cell ruby to be aligned in the 'distribute-space' mode:
869 <div class="figure">
870 <p><img width="145" height="91"
871 alt="Diagram of glyph layout in auto aligned ruby when ruby text is shorter than base"
872 src="images/ra-ds.gif" /><img width="145" height="91"
873 alt="Diagram of glyph layout in auto aligned ruby when ruby text is longer than base"
874 src="images/ra-ds-rb.gif" /></p>
875 <p><b>Figure 4.2.1</b>: Wide-cell text in 'auto' ruby alignment is
876 'distribute-space' justified</p>
877 </div>
879 <p>The recommended behavior for narrow-cell glyph ruby is to be
880 aligned in the 'center' mode.</p>
881 <div class="figure">
882 <p><img
883 alt="Diagram of glyph layout in auto aligned ruby when halfwidth ruby text is shorter than base"
884 width="145" height="91"
885 src="images/ra-c-h.gif" /><img
886 alt="Diagram of character layout in auto aligned ruby when ruby text is longer than narrow-width base"
887 width="145" height="91"
888 src="images/ra-c-rb-h.gif" /></p>
889 <p><b>Figure 4.2.2</b>: Narrow-width ruby text in 'auto' ruby alignment
890 is centered</p>
891 </div>
892 </dd>
894 <dt><dfn title="ruby-align:start">''start''</dfn></dt>
895 <dd>The ruby text content is aligned with the start edge of the base.
896 <p class="issue"><span class="issuehead">Issue: </span> The i18n WG feels that start and left should not be synonymous, and proposed to drop left (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>
898 <div class="figure">
899 <p><img
900 alt="Diagram of glyph layout in left aligned ruby when ruby text is shorter than base"
901 width="145" height="91" src="images/ra-l.gif" /><img
902 width="145" height="91"
903 alt="Diagram of glyph layout in left aligned ruby when ruby text is longer than base"
904 src="images/ra-l-rb.gif" /></p>
905 <p><b>Figure 4.2.3</b>: Start ruby alignment</p>
906 </div>
907 </dd>
909 <dt><dfn title="ruby-align:center">''center''</dfn></dt>
910 <dd>The ruby text content is centered within the width of the base. If the
911 length of the base is smaller than the length of the ruby text, then the
912 base is centered within the width of the ruby text.
914 <div class="figure">
915 <p><img width="145" height="91"
916 alt="Diagram of glyph layout in center aligned ruby when ruby text is shorter than base"
917 src="images/ra-c.gif" /><img width="145" height="91"
918 alt="Diagram of glyph layout in center aligned ruby when ruby text is longer than base"
919 src="images/ra-c-rb.gif" /></p>
920 <p><b>Figure 4.2.4</b>: Center ruby alignment</p>
921 </div>
922 </dd>
924 <!--
925 <dt><strong>right</strong></dt>
926 <dd>The ruby text content is aligned with the end edge of the base.
927 <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>
928 <div class="figure">
929 <p><img class="example" width="145" height="91"
930 alt="Diagram of glyph layout in right aligned ruby when ruby text is shorter than base"
931 src="images/ra-r.gif" /><img class="example" width="145" height="91"
932 alt="Diagram of glyph layout in right aligned ruby when ruby text is longer than base"
933 src="images/ra-r-rb.gif" /></p>
934 <p><b>Figure 4.2.5</b>: End ruby alignment</p>
935 </div>
936 </dd>
937 -->
939 <dt><dfn title="ruby-align:distribute-letter">''distribute-letter''</dfn></dt>
940 <dd>If the width of the ruby text is smaller than that of the base, then
941 the ruby text contents are evenly distributed across the width of the
942 base, with the first and last ruby text glyphs lining up with the
943 corresponding first and last base glyphs. If the width of the ruby text
944 is at least the width of the base, then the letters of the base are
945 evenly distributed across the width of the ruby text.
947 <div class="figure">
948 <p><img width="145" height="91"
949 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is shorter than base"
950 src="images/ra-dl.gif" /><img width="145" height="91"
951 alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is longer than base"
952 src="images/ra-dl-rb.gif" /></p>
953 <p><b>Figure 4.2.6</b>: Distribute-letter ruby alignment</p>
954 </div>
955 </dd>
957 <dt><dfn title="ruby-align:distribute-space">''distribute-space''</dfn></dt>
958 <dd>If the width of the ruby text is smaller than that of the base, then
959 the ruby text contents are evenly distributed across the width of the
960 base, with a certain amount of white space preceding the first and
961 following the last character in the ruby text. That amount of white
962 space is normally equal to half the amount of inter-character space of
963 the ruby text. If the width of the ruby text is at least the width of
964 the base, then the same type of space distribution applies to the base.
965 In other words, if the base is shorter than the ruby text, the base is
966 distribute-space aligned. This type of alignment
967 is described by [[JLREQ]].
969 <div class="figure">
970 <p><img width="145" height="91"
971 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is shorter than base"
972 src="images/ra-ds.gif" /><img width="145" height="91"
973 alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is longer than base"
974 src="images/ra-ds-rb.gif" /></p>
975 <p><b>Figure 4.2.7</b>: Distribute-space ruby alignment</p>
976 </div>
977 </dd>
979 <!--
980 <dt><strong>line-edge</strong></dt>
981 <dd>If the ruby text is not adjacent to a line edge, it is aligned as in
982 'auto'. If it is adjacent to a line edge, then it is still aligned as in
983 auto, but the side of the ruby text that touches the end of the line is
984 lined up with the corresponding edge of the base. This type of alignment
985 is described by [[JLREQ]]. This type of alignment is
986 relevant only to the scenario where the ruby text is longer than the
987 ruby base. In the other scenarios, this is just 'auto'.
988 <div class="figure">
989 <p><img class="example" width="146" height="109"
990 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base"
991 src="images/ra-le-l.gif" /><img class="example" width="146"
992 height="110"
993 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base"
994 src="images/ra-le-r.gif" /></p>
995 <p><b>Figure 4.2.8</b>: Line edge ruby alignment</p>
996 </div>
997 </dd>
998 -->
999 </dl>
1001 <p>For a complex ruby with spanning elements, one additional consideration is
1002 required. If the spanning element spans multiple 'rows' (other rbc or rtc
1003 elements), and the ruby alignment requires space distribution among the
1004 'spanned' elements, a ratio must be determined among the 'columns' of spanned
1005 elements. This ratio is computed by taking into consideration the widest
1006 element within each column.</p>
1008 <h2 id="rubyover">
1009 Ruby Overhang and Edge Effects</h2>
1011 <p>
1012 When <i>ruby annotation box</i> is longer than its corresponding <i>ruby base box</i>,
1013 the <i>ruby annotation box</i> may partially overhang adjacent boxes.
1014 </p>
1015 <p>
1016 This level of the specificaiton does not define
1017 how much the overhang may be allowed, and under what conditions.
1018 </p>
1019 <div class="example">
1020 <p>
1021 The user agent may use [[JIS4051]] recommendation of
1022 using one ruby text character length as the maximum overhang length.
1023 Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].
1024 </p>
1025 </div>
1027 <p>
1028 When such <i>ruby annotation box</i> is at the start or end edge of a line,
1029 user agent may align the side of the ruby text that touches the edge of the line
1030 to the corresponding edge of the base.
1031 This type of alignment is described by [[JLREQ]].
1032 </p>
1033 <p>
1034 This level of the specificaiton does not provide a mechanism to control this behavior.
1035 </p>
1036 <div class="figure">
1037 <p><img width="146" height="109"
1038 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base"
1039 src="images/ra-le-l.gif" /><img width="146"
1040 height="110"
1041 alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base"
1042 src="images/ra-le-r.gif" /></p>
1043 <p><b>Figure 4.2.8</b>: Line edge ruby alignment</p>
1044 </div>
1046 <!--
1047 <h3 id="rubyover">
1048 Ruby overhanging: the 'ruby-overhang' property</h3>
1050 <table class="propdef">
1051 <tr>
1052 <th>Name:
1053 <td><dfn>ruby-overhang</dfn>
1054 <tr>
1055 <th>Value:
1056 <td>auto | start | end | none
1057 <tr>
1058 <th>Initial:
1059 <td>none
1060 <tr>
1061 <th>Applies to:
1062 <td>the parent of elements with display: ruby-text
1063 <tr>
1064 <th>Inherited:
1065 <td>yes
1066 <tr>
1067 <th>Percentages:
1068 <td>N/A
1069 <tr>
1070 <th>Media:
1071 <td>visual
1072 <tr>
1073 <th>Computed value:
1074 <td>specified value (except for initial and inherit)
1075 </table>
1077 <p>This property determines whether, and on which side, ruby text is allowed
1078 to partially overhang any adjacent text in addition to its own base, when the
1079 ruby text is wider than the ruby base. Note that ruby text is never allowed to
1080 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
1081 a maximum amount by which ruby text may overhang adjacent text. The user agent may use
1082 the [[JIS4051]] recommendation of using one ruby text character
1083 length as the maximum overhang length. Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].</p>
1085 <p>Possible values:</p>
1086 <dl>
1087 <dt><strong>auto</strong></dt>
1088 <dd>The ruby text can overhang text adjacent to the base on either side. [[JLREQ]] and [[JIS4051]] specify the categories of characters that
1089 ruby text can overhang. The user agent is free to follow those recommendations or specify its own classes of
1090 characters to overhang. This is the initial value.
1091 <div class="figure">
1092 <p><img class="example" width="177" height="91"
1093 alt="Diagram of glyph layout in overhanging ruby" src="images/ro-a.gif" /></p>
1094 <p><b>Figure 4.3.1</b>: Ruby overhanging adjacent text</p>
1095 </div>
1096 </dd>
1097 <dt><strong>start</strong></dt>
1098 <dd>The ruby text can only overhang the text that precedes it. That means, for
1099 example, that ruby cannot overhang text that is to the right of it in
1100 horizontal LTR layout, and it cannot overhang text that is below it in
1101 vertical-ideographic layout.
1102 <div class="figure">
1103 <p><img class="example" width="199" height="91"
1104 alt="Diagram of glyph layout when ruby overhangs the preceding glyphs only"
1105 src="images/ro-s.gif" /></p>
1106 <p><b>Figure 4.3.2</b>: Ruby overhanging preceding text only</p>
1107 </div>
1108 </dd>
1109 <dt><strong>end</strong></dt>
1110 <dd>The ruby text can only overhang the text that follows it. That means, for
1111 example, that ruby cannot overhang text that is to the left of it in
1112 horizontal LTR layout, and it cannot overhang text that is above it in
1113 vertical-ideographic layout.
1114 <div class="figure">
1115 <p><img class="example" width="198" height="91"
1116 alt="Diagram of glyph layout when ruby overhangs the following characters only"
1117 src="images/ro-e.gif" /></p>
1118 <p><b>Figure 4.3.3</b>: Ruby overhanging following text only</p>
1119 </div>
1120 </dd>
1121 <dt><strong>none</strong></dt>
1122 <dd>The ruby text cannot overhang any text adjacent to its base, only its
1123 own base.
1125 <div class="figure">
1126 <p><img class="example" width="220" height="91"
1127 alt="Diagram of glyph layout in non-overhanging ruby"
1128 src="images/ro-n.gif" /></p>
1129 <p><b>Figure 4.3.4</b>: Ruby not allowed to overhang adjacent text</p>
1130 </div>
1131 </dd>
1132 </dl>
1134 <h3 id="rubyspan">
1135 Ruby annotation spanning: the 'ruby-span' property</h3>
1137 <table class="propdef">
1138 <tr>
1139 <th>Name:
1140 <td><dfn>ruby-span</dfn>
1141 <tr>
1142 <th>Value:
1143 <td>attr(x) | none
1144 <tr>
1145 <th>Initial:
1146 <td>none
1147 <tr>
1148 <th>Applies to:
1149 <td>elements with display: ruby-text
1150 <tr>
1151 <th>Inherited:
1152 <td>no
1153 <tr>
1154 <th>Percentages:
1155 <td>N/A
1156 <tr>
1157 <th>Media:
1158 <td>visual
1159 <tr>
1160 <th>Computed value:
1161 <td><number>
1162 </table>
1164 <p>This property controls the spanning behavior of annotation elements. </p>
1166 <p class="note"><span class="note-label">Note:</span> A XHTML user agent may also use the <samp>rbspan</samp>
1167 attribute to get the same effect.</p>
1169 <p>Possible values:</p>
1171 <dl>
1172 <dt><strong>attr(x)</strong></dt>
1173 <dd>The value of attribute 'x' as a string value. The string value is
1174 evaluated as a <number> to determine the number of ruby base elements to be
1175 spanned by the annotation element. If the <number> is '0', it is replaced by
1176 '1'.The <number> is the computed value. </dd>
1177 <dt>none</dt>
1178 <dd>No spanning. The computed value is '1'.</dd>
1179 </dl>
1181 <p>The following example shows an XML example using the 'display' property
1182 values associated with the 'ruby structure and the 'ruby-span' property</p>
1183 <pre class="xml">myruby { display: ruby; }
1184 myrbc { display: ruby-base-container; }
1185 myrb { display: ruby-base; }
1186 myrtc.before { display: ruby-text-container; ruby-position: before}
1187 myrtc.after { display: ruby-text-container; ruby-position: after}
1188 myrt { display: ruby-text; ruby-span: attr(rbspan); }
1189 ...
1190 <myruby>
1191 <myrbc>
1192 <myrb>10</myrb>
1193 <myrb>31</myrb>
1194 <myrb>2002</myrb>
1195 </myrbc>
1196 <myrtc class="before">
1197 <myrt>Month</myrt>
1198 <myrt>Day</myrt>
1199 <myrt>Year</myrt>
1200 </myrtc>
1201 <myrtc class="after">
1202 <myrt rbspan="3">Expiration Date</myrt>
1203 </myrtc>
1204 </myruby></pre>
1205 -->
1207 <h2 id="default-stylesheet" class="no-num">
1208 Appendix A: Default Style Sheet</h2>
1210 <p><em>This section is informative.</em>
1212 <h3 id="default-ua-ruby" class="no-num">
1213 <span class="secno">A.1</span> Supporting Ruby Layout</h3>
1215 <p>The following represents a default UA style sheet
1216 for rendering HTML and XHTML ruby markup as ruby layout:
1218 <pre>
1219 <!-- -->ruby { display: ruby; }
1220 <!-- -->rb { display: ruby-base; white-space: nowrap; }
1221 <!-- -->rt { display: ruby-text; white-space: nowrap; font-size: 50%; }
1222 <!-- -->rbc { display: ruby-base-container; }
1223 <!-- -->rtc { display: ruby-text-container; }</pre>
1225 <p>Additional rules for UAs supporting the relevant features of [[CSS3-TEXT-DECOR]] and [[CSS3-FONTS]]:
1226 <pre>rt { font-variant-east-asian: ruby; text-emphasis: none; }</pre>
1228 <p class="note">Authors should not use the above rules;
1229 a UA that supports ruby layout should provide these by default.
1231 <h3 id="default-inline" class="no-num">
1232 <span class="secno">A.2</span> Inlining Ruby Annotations</h3>
1234 <p>The following represents a sample style sheet
1235 for rendering HTML and XHTML ruby markup as inline annotations:
1237 <pre>ruby, rb, rt, rbc, rtc, rp {
1238 <!-- --> display: inline; white-space: inherit;
1239 <!-- --> font-variant-east-asian: inherit; text-emphasis: inherit; }</pre>
1241 <h3 id="default-parens" class="no-num">
1242 <span class="secno">A.3</span> Generating Parentheses</h3>
1244 <p>Unfortunately, because Selectors cannot match against text nodes,
1245 it's not possible with CSS to express rules that will automatically and correctly
1246 add parentheses to unparenthesized ruby annotations in HTML.
1247 (This is because HTML ruby allows implying the <i>ruby base</i> from raw text, without a corresponding element.)
1248 However, these rules will handle cases where either <code><rb></code>
1249 or <code><rtc></code> is used rigorously.
1251 <pre>
1252 <!-- -->/* Parens around <rtc> */
1253 <!-- -->rtc::before { content: "("; }
1254 <!-- -->rtc::after { content: ")"; }
1256 <!-- -->/* Parens before first <rt> not inside <rtc> */
1257 <!-- -->rb + rt::before,
1258 <!-- -->rtc + rt::before { content: "("; }
1260 <!-- -->/* Parens after <rt> not inside <rtc> */
1261 <!-- -->rb ~ rt:last-child::after,
1262 <!-- -->rt + rb::before { content: ")"; }
1263 <!-- -->rt + rtc::before { content: ")("; }</pre>
1265 <h2 id="glossary">
1266 Glossary</h2>
1267 <dl>
1268 <dt><a id="g-bopomofo"><strong><span
1269 lang="zh">Bopomofo</span></strong></a></dt>
1270 <dd>37 characters and 4 tone markings used as phonetics in Chinese,
1271 especially standard Mandarin.</dd>
1272 <dt><a id="g-hanja"><strong><span
1273 lang="ko">Hanja</span></strong></a></dt>
1274 <dd>Subset of the Korean writing system that utilizes ideographic
1275 characters borrowed or adapted from the Chinese writing system. Also see
1276 <a href="#g-kanji"><span lang="ja">Kanji</span></a>.</dd>
1277 <dt><a id="g-hiragana"><strong><span
1278 lang="ja">Hiragana</span></strong></a></dt>
1279 <dd>Japanese syllabic script, or character of that script. Rounded and
1280 cursive in appearance. Subset of the Japanese writing system, used together
1281 with kanji and katakana. In recent times, mostly used to write Japanese
1282 words when kanji are not available or appropriate, and word endings and
1283 particles. Also see <a
1284 href="#g-katakana"><span lang="ja">Katakana</span></a>.</dd>
1285 <dt><a id="g-ideogram"><strong>Ideograph</strong></a></dt>
1286 <dd>A character that is used to represent an idea, word, or word component,
1287 in contrast to a character from an alphabetic or syllabic script. The most
1288 well-known ideographic script is used (with some variation) in East Asia
1289 (China, Japan, Korea,...).</dd>
1290 <dt><a id="g-kana"><strong><span lang="ja">Kana</span></strong></a></dt>
1291 <dd>Collective term for hiragana and katakana.</dd>
1292 <dt><a id="g-kanji"><strong>Kanji</strong></a></dt>
1293 <dd>Japanese term for ideographs; ideographs used in Japanese. Subset of the
1294 Japanese writing system, used together with hiragana and katakana. Also see <a
1295 href="#g-hanja"><span lang="ko">Hanja</span></a>.</dd>
1296 <dt><a id="g-katakana"><strong><span
1297 lang="ja">Katakana</span></strong></a></dt>
1298 <dd>Japanese syllabic script, or character of that script. Angular in
1299 appearance. Subset of the Japanese writing system, used together with
1300 kanji and hiragana. In recent times, mainly used to write foreign words. Also see <a
1301 href="#g-hiragana"><span lang="ja">Hiragana</span></a>.</dd>
1302 <dt><a id="g-monoruby" name="g-monoruby"><strong>Mono-ruby</strong></a></dt>
1303 <dd>In Japanese typography: Ruby associated with a single character of
1304 the base text.</dd>
1305 <dt><a id="g-ruby"><strong>Ruby</strong></a></dt>
1306 <dd>A run of text that appears in the vicinity of another run of text and
1307 serves as an annotation or a pronunciation guide for that text.</dd>
1308 </dl>
1310 <h2 id="conformance">
1311 Conformance</h2>
1313 <h3 id="conventions">
1314 Document conventions</h3>
1316 <p>Conformance requirements are expressed with a combination of
1317 descriptive assertions and RFC 2119 terminology. The key words “MUST”,
1318 “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
1319 “RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
1320 document are to be interpreted as described in RFC 2119.
1321 However, for readability, these words do not appear in all uppercase
1322 letters in this specification.
1324 <p>All of the text of this specification is normative except sections
1325 explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
1327 <p>Examples in this specification are introduced with the words “for example”
1328 or are set apart from the normative text with <code>class="example"</code>,
1329 like this:
1331 <div class="example">
1332 <p>This is an example of an informative example.</p>
1333 </div>
1335 <p>Informative notes begin with the word “Note” and are set apart from the
1336 normative text with <code>class="note"</code>, like this:
1338 <p class="note">Note, this is an informative note.</p>
1340 <h3 id="conformance-classes">
1341 Conformance classes</h3>
1343 <p>Conformance to CSS Ruby Module
1344 is defined for three conformance classes:
1345 <dl>
1346 <dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
1347 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
1348 style sheet</a>.
1349 <dt><dfn>renderer</dfn></dt>
1350 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1351 that interprets the semantics of a style sheet and renders
1352 documents that use them.
1353 <dt><dfn id="authoring-tool">authoring tool</dfn></dt>
1354 <dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
1355 that writes a style sheet.
1356 </dl>
1358 <p>A style sheet is conformant to CSS Ruby Module
1359 if all of its statements that use syntax defined in this module are valid
1360 according to the generic CSS grammar and the individual grammars of each
1361 feature defined in this module.
1363 <p>A renderer is conformant to CSS Ruby Module
1364 if, in addition to interpreting the style sheet as defined by the
1365 appropriate specifications, it supports all the features defined
1366 by CSS Ruby Module by parsing them correctly
1367 and rendering the document accordingly. However, the inability of a
1368 UA to correctly render a document due to limitations of the device
1369 does not make the UA non-conformant. (For example, a UA is not
1370 required to render color on a monochrome monitor.)
1372 <p>An authoring tool is conformant to CSS Ruby Module
1373 if it writes style sheets that are syntactically correct according to the
1374 generic CSS grammar and the individual grammars of each feature in
1375 this module, and meet all other conformance requirements of style sheets
1376 as described in this module.
1378 <h3 id="partial">
1379 Partial implementations</h3>
1381 <p>So that authors can exploit the forward-compatible parsing rules to
1382 assign fallback values, CSS renderers <strong>must</strong>
1383 treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
1384 as appropriate</a>) any at-rules, properties, property values, keywords,
1385 and other syntactic constructs for which they have no usable level of
1386 support. In particular, user agents <strong>must not</strong> selectively
1387 ignore unsupported component values and honor supported values in a single
1388 multi-value property declaration: if any value is considered invalid
1389 (as unsupported values must be), CSS requires that the entire declaration
1390 be ignored.</p>
1392 <h3 id="experimental">
1393 Experimental implementations</h3>
1395 <p>To avoid clashes with future CSS features, the CSS2.1 specification
1396 reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
1397 syntax</a> for proprietary and experimental extensions to CSS.
1399 <p>Prior to a specification reaching the Candidate Recommendation stage
1400 in the W3C process, all implementations of a CSS feature are considered
1401 experimental. The CSS Working Group recommends that implementations
1402 use a vendor-prefixed syntax for such features, including those in
1403 W3C Working Drafts. This avoids incompatibilities with future changes
1404 in the draft.
1405 </p>
1407 <h3 id="testing">
1408 Non-experimental implementations</h3>
1410 <p>Once a specification reaches the Candidate Recommendation stage,
1411 non-experimental implementations are possible, and implementors should
1412 release an unprefixed implementation of any CR-level feature they
1413 can demonstrate to be correctly implemented according to spec.
1415 <p>To establish and maintain the interoperability of CSS across
1416 implementations, the CSS Working Group requests that non-experimental
1417 CSS renderers submit an implementation report (and, if necessary, the
1418 testcases used for that implementation report) to the W3C before
1419 releasing an unprefixed implementation of any CSS features. Testcases
1420 submitted to W3C are subject to review and correction by the CSS
1421 Working Group.
1423 <p>Further information on submitting testcases and implementation reports
1424 can be found from on the CSS Working Group's website at
1425 <a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
1426 Questions should be directed to the
1427 <a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
1428 mailing list.
1430 <h2 class=no-num id="acknowledgments">
1431 Acknowledgments</h2>
1433 <p>This specification would not have been possible without the help from:</p>
1435 <p>Stephen Deach, Martin Dürst, Hideki Hiura(<span lang="ja">樋浦 秀樹</span>), Masayasu Ishikawa(<span lang="ja">石川
1436 雅康</span>), Chris
1437 Pratley, Takao Suzuki(<span lang="ja">鈴木 孝雄</span>), Frank Yung-Fong Tang, Chris Thrasher, Masafumi Yabe<span lang="ja">家辺
1438 勝文</span>), Steve Zilles.</p>
1440 <h2 class=no-num id="references">
1441 References</h2>
1443 <h3 class="no-num" id="normative-references">
1444 Normative references</h3>
1445 <!--normative-->
1447 <h3 class="no-num" id="other-references">
1448 Other references</h3>
1449 <!--informative-->
1451 <h2 class="no-num" id="index">
1452 Index</h2>
1453 <!--index-->
1455 <h2 class="no-num" id="property-index">
1456 Property index</h2>
1457 <!-- properties -->
1459 </body>
1460 </html>
1461 <!-- Keep this comment at the end of the file
1462 Local variables:
1463 mode: sgml
1464 sgml-declaration:"~/SGML/HTML4.decl"
1465 sgml-default-doctype-name:"html"
1466 sgml-minimize-attributes:t
1467 sgml-nofill-elements:("pre" "style" "br")
1468 sgml-live-element-indicator:t
1469 sgml-omittag:nil
1470 sgml-shorttag:nil
1471 sgml-namecase-general:t
1472 sgml-general-insert-case:lower
1473 sgml-always-quote-attributes:t
1474 sgml-indent-step:nil
1475 sgml-indent-data:t
1476 sgml-parent-document:nil
1477 sgml-exposed-tags:nil
1478 sgml-local-catalogs:nil
1479 sgml-local-ecat-files:nil
1480 End:
1481 -->