-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.src.html
More file actions
1470 lines (1258 loc) · 60 KB
/
Overview.src.html
File metadata and controls
1470 lines (1258 loc) · 60 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
Issues:
white space
line breaking
bidi
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS Ruby Module Level 1</title>
<link rel=contents href="#contents">
<link rel=index href="#index">
<link rel="stylesheet" type="text/css" href="../default.css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
</head>
<body class="h-entry">
<div class="head">
<!--logo-->
<h1 class="p-name">CSS Ruby Module Level 1</h1>
<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>
<dl>
<dt>This version:
<dd><a class="u-url" href="[VERSION]">[VERSION]</a>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/[SHORTNAME]/">http://www.w3.org/TR/css3-ruby/</a>
<dt>Editor's draft:
<dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
(<a href="https://dvcs.w3.org/hg/csswg/log/tip/[SHORTNAME]/Overview.src.html">change log</a>)
<dt>Previous version:
<dd><a href="http://www.w3.org/TR/2011/WD-css3-ruby-20110630/">
http://www.w3.org/TR/2011/WD-css3-ruby-20110630/</a>
<dt>Issue Tracking:</dt>
<dd><a rel="issues" href="http://www.w3.org/Style/CSS/Tracker/products/FIXME">http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5BSHORTNAME%5D%20feedback"
>www-style@w3.org</a>
with subject line “<kbd>[[SHORTNAME]]
<var>… message topic …</var></kbd>”
(<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/"
>archives</a>)
<dt>Editors:
<dd class="p-author h-card vcard">
<a class="p-name fn u-url url" rel="author"
href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a>,
<a class="p-org org h-org" href="http://www.mozilla.org/">Mozilla</a>
<dd class="p-author h-card vcard">
<a class="p-name fn u-url url" rel="author"
href="mailto:koji.a.ishii@mail.rakuten.com">Koji Ishii</a>,
<span class="p-org org">Rakuten, Inc.</span>
<dd class="p-author h-card vcard">
<a class="p-name fn u-url url" rel="author"
href="mailto:ishida@w3.org">Richard Ishida</a>,
<span class="p-org org">W3C</span>
<dt>Former editors:
<dd>Michel Suignard, Microsoft
<dd>Marcin Sawicki, Microsoft
</dl>
<!--copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
<p>
<span class="p-summary">
“Ruby” are short runs of text alongside the base text,
typically used in East Asian documents to indicate pronunciation
or to provide a short annotation.
This module describes the rendering model and formatting controls
related to displaying ruby annotations in CSS.
</span>
<a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing
the rendering of structured documents (such as HTML and XML) on screen, on
paper, in speech, etc.
<h2 class="no-num no-toc" id="status">Status of this document</h2>
<!--status-->
<p>The following features are at risk: …
<h2 class="no-num no-toc" id="contents">
Table of Contents</h2>
<!--toc-->
<h2 id="intro">
Introduction</h2>
<p><em>This section is not normative.</em>
<h3 id="placement">
Module interactions</h3>
<p>This module extends the inline box model of CSS Level 2 [[!CSS21]]
to support ruby.
<p>None of the properties in this module apply to the <code>::first-line</code> or
<code>::first-letter</code> pseudo-elements.
<h3 id="values">
Values</h3>
<p>This specification follows the
<a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from [[!CSS21]]. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
Other CSS modules may expand the definitions of these value types: for
example [[CSS3VAL]], when combined with this module, expands the
definition of the <var><length></var> value type as used in this specification.</p>
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the
<a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h3 id="conventions">
Document conventions</h3>
<p>Many typographical conventions in East Asian typography depend
on whether the character rendered is wide (CJK) or narrow (non-CJK).
There are a number of illustrations in this document
for which the following legend is used:
<dl>
<dt><img alt="Symbolic wide-cell glyph representation" width="39" height="39" src="images/fullwidth.gif">
<dd>Wide-cell glyph (e.g. Han) that is the <var>n</var>th character in the text run.
They are typically sized to 50% when used as annotations.
<dt><img alt="Symbolic narrow-cell glyph representation" width="19" height="39" src="images/halfwidth.gif">
<dd>Narrow-cell glyph (e.g. Roman) which is the <var>n</var>th glyph in the text run.
</dl>
<p>The orientation which the above symbols assume in the diagrams
corresponds to the orientation that the glyphs they represent
are intended to assume when rendered by the user agent.
Spacing between these characters in the diagrams is incidental,
unless intentionally changed to make a point.
<h3 id="ruby-def">
What is ruby?</h3>
<p><dfn>Ruby</dfn> is the commonly-used name for a run of text
that appears alongside another run of text (referred to as the “base”)
and serves as an annotation or a pronunciation guide associated with that run of text.
<p>The following figures show two examples of Ruby,
a simple case and one with more complicated structure.
<div class="example">
<p>In this first example, a single annotation is used to annotate the base text.
<div class="figure">
<p><img src="images/licence.png"
alt="Example of ruby applied on top of a Japanese expression">
<p class="caption">Example of ruby used in Japanese (simple case)
</div>
<p>In Japanese typography, this case is sometimes called
<i lang="ja">taigo</i> ruby or group-ruby (per-word ruby),
because the annotation as a whole is associated
with multi-character word (as a whole).
</div>
<div class="example">
<p>In this second example,
two levels of annotations are attached to a base sequence:
the hiragana characters on top refer to the pronunciation of each of the base kanji characters,
while the words “Keio” and “University” on the bottom are annotations describing the English translation.
<div class="figure">
<p><img src="images/ruby-univ.gif"
alt="Example showing complex ruby with annotation text over and under the base characters">
<p class="caption">Complex ruby with annotation text over and under the base characters
</div>
<p>
<p>Notice that to allow correct association between the hiragana characters and
their corresponding Kanji base characters,
the spacing between these Kanji characters is adjusted.
(This happens around the fourth Kanji character in the figure above.)
To avoid variable spacing between the Kanji characters in the example above
the hiragana annotations can be styled as a <i>collapsed annotation</i>,
which will look more like the group-ruby example earlier.
However because the base-annotation pairings are recorded in the ruby structure,
if the text breaks across lines, the annotation characters will stay
correctly paired with their respective base characters.
</div>
<p><i>Ruby</i> formatting as used in Japanese is described in JIS X-4051 [[JIS4051]] (in Japanese)
and in Requirements for Japanese Text Layout [[JLREQ]] (in English and Japanese)].
In HTML, ruby structure and markup to represent it is described
in the Ruby Markup Extension specification.
This module describes the CSS rendering model
and formatting controls relevant to ruby layout of such markup.
<h2 id="ruby-model">
Ruby Formatting Model</h2>
<p>The CSS ruby model is based on
the <a href="http://darobin.github.io/html-ruby/">HTML Ruby Markup Extension</a>
and <a href="http://www.w3.org/TR/ruby/">XHTML Ruby Annotation Recommendation</a> [[RUBY]].
In this model, a ruby structure consists of
one or more <dfn>ruby base</dfn> elements representing the base (annotated) text,
associated with one or more levels of <dfn>ruby annotation</dfn> elements representing the annotations.
The structure of ruby is similar to that of a table:
there are “rows” (the base text level, each annotation level)
and “columns” (each <i>ruby base</i> and its corresponding <i>ruby annotations</i>).
<p>Consecutive bases and annotations are grouped together into <dfn>ruby segments</dfn>.
Within a <i>ruby segment</i>, a <i>ruby annotation</i> may span multiple <i>ruby bases<i>.
<p class="note">In HTML, a single <code><ruby></code> element may contain multiple <i>ruby segments</i>.
(In the XHTML Ruby model, a single <code><ruby></code> element can only contain one <i>ruby segment</i>.)
<h3 id="ruby-display">
Ruby-specific 'display' property values</h3>
<p>For document languages (such as XML applications) that do not have pre-defined ruby elements,
authors must map document language elements to ruby elements;
this is done with the 'display' property.
<table class="propdef">
<tr>
<th>Name:
<td>display
<tr>
<th><a href="#values">New Values</a>:
<td>ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container
</table>
<p>The following new 'display' values assign ruby layout roles to an arbitrary element:
<dl>
<dt>''ruby''
<dd>Specifies that an element generates a <dfn title="ruby container | ruby container box">ruby container box</dfn>.
(Corresponds to HTML/XHTML <code><ruby></code> elements.)
<dt>''ruby-base''
<dd>Specifies that an element generates a <dfn title="ruby base box | ruby base">ruby base box</dfn>.
(Corresponds to HTML/XHTML <code><rb></code> elements.)
<dt>''ruby-text''
<dd>Specifies that an element generates a <dfn title="ruby annotation box | ruby annotation">ruby annotation box</dfn>.
(Corresponds to HTML/XHTML <code><rt></code> elements.)
<dt>''ruby-base-container''
<dd>Specifies that an element generates a <dfn title="ruby base container box | ruby base container">ruby base container box</dfn>.
(Corresponds to XHTML <code><rbc></code> elements; always implied in HTML.)
<dt>''ruby-text-container''
<dd>Specifies that an element generates a <dfn title="ruby annotation container box | ruby annotation container">ruby annotation container box</dfn>.
(Corresponds to HTML/XHTML <code><ruby></code> elements.)
</dl>
<h3 id="box-fixup">
Anonymous Ruby Box Generation</h3>
<p>The CSS model does not require that the document language
include elements that correspond to each of these components.
Missing parts of the structure are implied through the anonymous box generation rules
<a href="http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes">similar to those used to normalize tables</a>. [[!CSS21]]
<ol>
<li>Any in-flow block-level boxes directly contained by a
<i>ruby container</i>,
<i>ruby base container</i>,
<i>ruby annotation container</i>,
<i>ruby base box</i>,
or <i>ruby annotation box</i>
are forced to be inline-level boxes,
and their 'display' value computed accordingly.
For example,
the 'display' property of an in-flow element with ''display: block''
parented by an element with ''display: ruby-text''
computes to ''inline-block''.
This computation occurs after any intermediary anonymous-box fixup
(such as that required by internal table elements).
<li>Any consecutive sequence of <i>ruby bases</i> not parented by a <i>ruby base container</i>
is wrapped in an anonymous <i>ruby base container</i>.
Similarly, any consecutive sequence of <i>ruby annotations</i> not parented by a <i>ruby annotation container</i>
is wrapped in an anonymous <i>ruby annotation container</i>.
<li>Within each <i>ruby base container</i>,
each sequence of inline-level boxes is wrapped in an anonymous <i>ruby base box</i>.
Similarly, within each <i>ruby annotation container</i>,
each sequence of inline-level boxes is wrapped in an anonymous <i>ruby annotation box</i>.
<li>A sequence of <i>ruby base containers</i> and/or <i>ruby annotation containers</i>
not parented by a <i>ruby container</i>
is wrapped in an anonymous <i>ruby container</i>.
</ol>
<p>At this point, all ruby layout structures are properly parented,
and the UA can start to associate bases with their annotations.
<p class="note">
Note that the UA is not required to create any of these anonymous boxes in its internal structures,
as long as pairing and layout behaves as if they existed.
<h3 id="pairing">
Ruby Pairing and Annotation Levels</h3>
<p>Within a ruby structure,
each <i>ruby bases</i> are associated with <i>ruby annotations</i>
and vice versa.
A <i>ruby base</i> can be associated with at most one <i>ruby annotation</i> per annotation level.
If there are multiple annotation levels, it can therefore be associated with multiple <i>ruby annotations</i>.
A <i>ruby annotation</i> is associated with one or more <i>ruby bases</i>;
annotations can span multiple bases.
<p><dfn>Annotation pairing</dfn> is the process of associating
<i>ruby annotations</i> with <i>ruby bases</i>.
<ol>
<li>
<p>First, the ruby structure is divided into <i>ruby segments</i>,
each consisting of a single <i>ruby base container</i>
followed by one or more <i>ruby annotation containers</i>.
If the first child of a <i>ruby container</i> is a <i>ruby annotation container</i>,
an anonymous, empty <i>ruby base container</i> is assumed to exist before it.
Similarly, if the <i>ruby container</i> contains consecutive <i>ruby base containers</i>,
anonymous, empty <i>ruby annotation containers</i> are assumed to exist between them.
The <i>ruby base container</i> in each segment is thus associated
with each of the <i>ruby annotation containers</i> in that segment.
<p>Each <i>ruby annotation containers</i> in a <i>ruby segment</i>
represents one <dfn title="annotation level | level">level</dfn> of annotation:
the first one represents the first level of annotation,
the second one represents the second level of annotation,
and so on.
<li>Within each <i>ruby segment</i>,
each <i>ruby base box</i> in the <i>ruby base container</i>
is paired with one <i>ruby annotation box</i>
from each <i>ruby annotation container</i> in its <i>ruby segment</i>.
If there are not enough <i>ruby annotations</i> in a <i>ruby annotation container</i>,
the last one is associated with any excess <i>ruby bases</i>.
(If there are not any in the <i>ruby annotation container</i>, an anonymous empty one is assumed to exist.)
If there are not enough <i>ruby bases</i>,
any remaining <i>ruby annotations</i> are assumed to be associated
with empty, anonymous bases inserted at the end of the <i>ruby base container</i>.
<p>If an implementation supports ruby markup with explicit spanning
(e.g. XHTML Complex Ruby Annotations),
it must adjust the pairing rules to pair spanning annotations to multiple bases
appropriately.
</ol>
<p>A this point, ruby “columns” are defined,
each represented by a single <i>ruby base</i>
and associated with one <i>ruby annotation</i> (possibly an empty, anonymous one)
from each <i>annotation level</i>.
<h4 id="nested-pairing">
Nested Ruby</h4>
<p>When <i>ruby containers</i> are nested,
pairing begins with the deepest <i>ruby container</i>,
then expands out,
treating each <i>ruby container</i> nested within another <i>ruby container</i>
as a <i>ruby base</i>,
and associating each <i>ruby annotation</i>
associated with the nested <i>ruby container</i>
as being associated with (spanning) all of its <i>ruby bases</i>.
<p>Using nested <i>ruby containers</i> thus allows the representation
of complex spanning relationships.
<p class="issue">This shouldn't belong in Level 1. But HTML5 allows it, so we have to handle it. Yay HTML5.
<h3 id="white-space">
White Space</h3>
<p class="issue">I'm unsure exactly where space should be trimmed. :/
But pretty sure we need to keep spaces between things,
otherwise ruby only works for CJK.
<p><i>Collapsible</i> white space within a ruby structure is discarded
at the beginning and end of a <i>ruby container</i>,
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.
Between <i>ruby segments</i>, between <i>ruby bases</i>, and between <i>ruby annotations</i>, however,
white space is not discarded.
If such white space is <i>collapsible</i>, it will collapse
following the standard <a href="http://www.w3.org/TR/css3-text/#white-space-rules">white space processing rules</a>. [[!CSS3-TEXT]]
Between <i>ruby segments</i>, however,
the contextual text for determining collapsing behavior is given by the <i>ruby bases</i> on either side,
not the text on either side of the white space in the source document.
<div class="note">
<p>Note that the white space processing rules
cause a white space sequence containing a <i>segment break</i> (such as a line feed)
to <a href="http://www.w3.org/TR/css3-text/#line-break-transform">collapse to nothing</a> between CJK characters.
This means that CJK ruby can safely use white space for indentation of the ruby markup.
For example, the following markup will display without any spaces:
<pre>
<!-- --><ruby>
<!-- --> <rb>東</rb><rb>京</rb>
<!-- --> <rt>とう</rt><rt>きょう</rt>
<!-- --></ruby></pre>
<p>However, this markup will:
<!-- --><ruby>
<!-- --> <rb>東</rb> <rb>京</rb>
<!-- --> <rt>とう</rt> <rt>きょう</rt>
<!-- --></ruby></pre>
</div>
<p>Any preserved white space is then wrapped in an anonymous box belonging to
the <i>ruby base container</i> (if between <i>ruby bases</i>),
<i>ruby annotation container</i> (if between <i>ruby annotations</i>),
or <i>ruby container</i> (if between <i>ruby segments</i>).
In the latter case, the text is considered part of the <i>base level</i>.
This box does not take part in pairing.
It merely ensures separation between adjacent bases/annotations.
<div class="example">
<p>These rules allow ruby to be used with space-separated scripts such as Latin.
For example,
<pre>
<!-- --><ruby>
<!-- --> <rb>W</rb><rb>W</rb><rb>W</rb>
<!-- --> <rt>World</rt> <rt>Wide</rt> <rt>Web</rt>
<!-- --></ruby></pre>
<p>They also ensure that annotated white space is preserved. For example,
<pre>
<!-- --><ruby>
<!-- --> <rb>Aerith</rb><rb> </rb><rb>Gainsboro</rb>
<!-- --> <rt>エアリス</rt><rt>・</rt><rt>ゲインズブール</rt>
<!-- --></ruby></pre>
</div>
<p class="issue">Specify how this impacts layout, or not.
<h3 id="line-breaking">
Ruby box and line breaking</h3>
<p>When there is not enough space for an entire <i>ruby container</i> to fit on the line,
the ruby may be broken wherever all levels allow a break.
In typical cases, line breaks are forbidden within each <i>ruby base</i> and <i>ruby annotation</i>,
so the <i>ruby container</i> can only break between adjacent <i>ruby bases</i>,
and only if no <i>ruby annotations</i> span those <i>ruby bases</i>.
Whenever ruby breaks across lines, <i>ruby annotations</i>
<em>must</i> stay with their respective bases.
<div class="figure">
<p><img src="images/r-break-a.gif"
alt="Diagram showing the line breaking opportunity in a complex ruby">
<p class="caption">Ruby line breaking opportunity
</div>
<p>Whether ruby can break between two adjacent <i>ruby bases</i>
is controlled by normal line-breaking rules for the affected text,
exactly as if the <i>ruby bases</i> were regular <i>inline</i> boxes.
<div class="example">
<p>For example, if two adjacent ruby bases are “蝴” and “蝶”,
the line may break between them,
because lines are normally allowed to break between two Han characters.
However, if 'word-break' is ''keep-all'', that line break is forbidden.
</div>
<p>Inter-base white space is significant for evaluating line break opportunities between <i>ruby bases</i>.
As with white space between inlines, it collapses when the line breaks there.
<div class="example">
<p>For example, given the following markup:
<pre><ruby><rb>one</rb> <rb>two</rb> <rt>1</rt> <rt>2</rt></ruby></pre>
<p>Due to the space, the line may break between “one” and “two“.
If the line breaks there, that space disappears,
in accordance with standard CSS white space processing rules. [[CSS3-TEXT]]
</div>
<p>The line <em>must not</em> break between a <i>ruby base</i> and its annotations.
<div class="figure">
<img src="images/r-break-b.gif"
alt='Diagram showing the line breaking opportunity in a "Bopomofo" ruby'>
<p class="caption">''inter-character'' ruby line breaking opportunity
</div>
<!-- <h3 id="ruby-line-height">
Ruby box and line stacking</h3>
<div class="figure">
<p>
<img class="example"
alt="Diagram showing the ruby text using 2 half leading"
src="images/rlh-a.gif" width="210" height="138" /></p>
<p><b>Figure 3.3.1</b>: Excluded Ruby text</p>
</div>
-->
<h2 id="ruby-props">
Ruby Properties</h2>
<p>The following properties are introduced to control ruby positioning and alignment.
<h3 id="rubypos">
Ruby positioning: the 'ruby-position' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>ruby-position</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>[ over | under | inter-character ] && [ right | left ]
<tr>
<th>Initial:
<td>over right
<tr>
<th>Applies to:
<td>ruby annotation containers
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per grammar</abbr>
</table>
<p>This property controls position of the ruby text with respect to its base.
Values have the following meanings:
<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>
<dl>
<dt><dfn title="ruby-position:over">''over''</dfn>
<dd>The ruby text appears <i>over</i> the base in horizontal text.
<div class="figure">
<p><img src="images/shinkansen-top.gif"
alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing above the base">
<p class="caption">Ruby over Japanese base text in horizontal layout
</div>
</dd>
<dt><dfn title="ruby-position:right">''right''</dfn>
<dd>The ruby text appears on the right side of the base in vertical text.
<div class="figure">
<p><img src="images/shinkansen-right.gif" width="33"
alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the right of the base">
<p class="caption">Ruby to the right of Japanese base text in vertical layout
</div>
</dd>
<dt><dfn title="ruby-position:under">''under''</dfn>
<dd>The ruby text appears under the base in horizontal text.
This is a relatively rare setting used in ideographic East Asian writing systems,
most easily found in educational text.
<div class="figure">
<p><img src="images/shinkansen-bottom.gif"
alt="Diagram of ruby glyph layout in horizontal mode with ruby text appearing below the base">
<p class="caption">Ruby under Japanese base text in horizontal layout
</div>
</dd>
<dt><dfn title="ruby-position:left">''left''</dfn>
<dd>The ruby text appears on the left side of the base in vertical text.
<div class="figure">
<p><img src="images/shinkansen-left.gif"
alt="Diagram of ruby glyph layout in vertical mode with ruby text apearing vertically on the left of the base">
<p class="caption">Ruby to the left of Japanese base text in vertical layout
</div>
</dd>
<dt><dfn title="ruby-position:inter-character">''inter-character''</dfn></dt>
<dd>
<p>The ruby text appears on the right of the base in horizontal text.
This value forces the 'writing-mode' of the <i>ruby annotation</i> to be vertical.
<p>This value is provided for the special case of traditional Chinese
as used especially in Taiwan:
ruby (made of <a href="#g-bopomofo">bopomofo</a> glyphs) in that context
appears vertically along the right side of the base glyph,
even when the layout of the base characters is horizontal:
<div class="figure">
<p><img src="images/bopomofo.gif"
alt="Example of Taiwanese-style ruby">
<p class="caption">“Bopomofo” ruby in traditional Chinese
(ruby text shown in blue for clarity) in horizontal layout
</div>
<p class="note">
Note that the user agent is responsible for ensuring the correct relative alignment and positioning of the glyphs,
including those corresponding to the 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.
<!-- See Taiwanese requirements doc for EPUB at http://epub-revision.googlecode.com/files/EGLS_TW_eng.ppt -->
</dd>
</dl>
<p>If multiple <i>ruby annotation containers</i> have the same 'ruby-position',
they stack along the block axis,
with lower levels of annotation closer to the base text.
<h3 id="collapsed-ruby">
Collapsed Ruby Annotations: the 'ruby-merge' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>ruby-merge</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>separate | collapse | auto
<tr>
<th>Initial:
<td>separate
<tr>
<th>Applies to:
<td>ruby annotation containers
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per grammar</abbr>
</table>
<p>
This property controls how ruby annotation boxes should be rendered
when there are more than one in a ruby container box.
<p>Possible values:</p>
<dl>
<dt><dfn title="ruby-merge:separate">''separate''</dfn>
<dd>
<p>
Each ruby annotation box is rendered in the same column(s) as its cor
67FD
responding base box(es).
This style is called “mono ruby” in [[JLREQ]].
<div class="example">
<p>For example, the following two markups render the same:
<pre><ruby>無<rt>む</ruby><ruby>常<rt>じょう</ruby></pre>
<p>and:
<pre><ruby style="ruby-merge:separate"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
</div>
</dd>
<dt><dfn title="ruby-merge:collapse">''collapse''</dfn>
<dd>
<p>
All <i>ruby annotation boxes</i> within the same <i>ruby segment</i> on the same line are concatenated,
and laid out as if their contents belonged to a single <i>ruby annotation box</i>
spanning all their associated <i>ruby base boxes.
This style renders similar to “group ruby” in [[JLREQ]],
except that <i>ruby annotations</i> are kept together with their respective <i>ruby bases</i> when breaking lines.
</p>
<div class="example">
<p>The following two markups render the same both characters fit on one line:
<pre><ruby>無常<rt>むじょう</ruby></pre>
<p>and:
<pre><ruby style="ruby-merge:collapse"><rb>無<rb>常<rt>む<rt>じょう</ruby></pre>
<p>However, the second one renders the same as ''ruby-position: separate''
when the two bases are split across lines.
</div>
</dd>
<dt><dfn title="ruby-merge:auto">''auto''</dfn></dt>
<dd>
<p>
The user agent may use any algorithm to determine how each ruby annotation box
is rendered to its corresponding base box.
<div class="example">
<p>
One possible algorithm is described as Jukugo-ruby in [[JLREQ]].
<p>
Another, more simplified algorithm of Jukugo-ruby is
to render as Mono-ruby if all ruby annotation boxes fit within
advances of their corresponding base boxes,
and render as Group-ruby otherwise.
</p>
</div>
</dd>
</dl>
<h3 id="rubyalign">
Ruby Text Distribution: the 'ruby-align' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>ruby-align</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | start | center |
distribute-letter | distribute-space
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>ruby bases, ruby annotations, ruby base containers, ruby annotation containers
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value (except for initial and inherit)
</table>
<p>This property specifies how text is distributed within the various ruby boxes
when their text contents exactly fill their respective boxes.
<p>Values have the following meanings:
<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>
<dl>
<dt><dfn title="ruby-align:auto">''auto''</dfn></dt>
<dd>
<p>The user agent determines how the ruby contents are aligned.
This is the initial value.
The behavior recommended by [[JLREQ]] is for wide-cell ruby to be aligned in the 'distribute-space' mode:
<div class="figure">
<p><img width="145" height="91"
alt="Diagram of glyph layout in auto aligned ruby when ruby text is shorter than base"
src="images/ra-ds.gif" /><img width="145" height="91"
alt="Diagram of glyph layout in auto aligned ruby when ruby text is longer than base"
src="images/ra-ds-rb.gif" /></p>
<p><b>Figure 4.2.1</b>: Wide-cell text in 'auto' ruby alignment is
'distribute-space' justified</p>
</div>
<p>The recommended behavior for narrow-cell glyph ruby is to be
aligned in the 'center' mode.</p>
<div class="figure">
<p><img
alt="Diagram of glyph layout in auto aligned ruby when halfwidth ruby text is shorter than base"
width="145" height="91"
src="images/ra-c-h.gif" /><img
alt="Diagram of character layout in auto aligned ruby when ruby text is longer than narrow-width base"
width="145" height="91"
src="images/ra-c-rb-h.gif" /></p>
<p><b>Figure 4.2.2</b>: Narrow-width ruby text in 'auto' ruby alignment
is centered</p>
</div>
</dd>
<dt><dfn title="ruby-align:start">''start''</dfn></dt>
<dd>The ruby annotation content is aligned with the start edge of the base.
<div class="figure">
<p><img
alt="Diagram of glyph layout in left aligned ruby when ruby text is shorter than base"
width="145" height="91" src="images/ra-l.gif" /><img
width="145" height="91"
alt="Diagram of glyph layout in left aligned ruby when ruby text is longer than base"
src="images/ra-l-rb.gif" /></p>
<p><b>Figure 4.2.3</b>: Start ruby alignment</p>
</div>
</dd>
<dt><dfn title="ruby-align:center">''center''</dfn></dt>
<dd>The ruby text content is centered within the width of the base. If the
length of the base is smaller than the length of the ruby text, then the
base is centered within the width of the ruby text.
<div class="figure">
<p><img width="145" height="91"
alt="Diagram of glyph layout in center aligned ruby when ruby text is shorter than base"
src="images/ra-c.gif" /><img width="145" height="91"
alt="Diagram of glyph layout in center aligned ruby when ruby text is longer than base"
src="images/ra-c-rb.gif" /></p>
<p><b>Figure 4.2.4</b>: Center ruby alignment</p>
</div>
</dd>
<!--
<dt><strong>right</strong></dt>
<dd>The ruby text content is aligned with the end edge of the base.
<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>
<div class="figure">
<p><img class="example" width="145" height="91"
alt="Diagram of glyph layout in right aligned ruby when ruby text is shorter than base"
src="images/ra-r.gif" /><img class="example" width="145" height="91"
alt="Diagram of glyph layout in right aligned ruby when ruby text is longer than base"
src="images/ra-r-rb.gif" /></p>
<p><b>Figure 4.2.5</b>: End ruby alignment</p>
</div>
</dd>
-->
<dt><dfn title="ruby-align:distribute-letter">''distribute-letter''</dfn></dt>
<dd>If the width of the ruby text is smaller than that of the base, then
the ruby text contents are evenly distributed across the width of the
base, with the first and last ruby text glyphs lining up with the
corresponding first and last base glyphs. If the width of the ruby text
is at least the width of the base, then the letters of the base are
evenly distributed across the width of the ruby text.
<div class="figure">
<p><img width="145" height="91"
alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is shorter than base"
src="images/ra-dl.gif" /><img width="145" height="91"
alt="Diagram of glyph layout in distribute-letter aligned ruby when ruby text is longer than base"
src="images/ra-dl-rb.gif" /></p>
<p><b>Figure 4.2.6</b>: Distribute-letter ruby alignment</p>
</div>
</dd>
<dt><dfn title="ruby-align:distribute-space">''distribute-space''</dfn></dt>
<dd>If the width of the ruby text is smaller than that of the base, then
the ruby text contents are evenly distributed across the width of the
base, with a certain amount of white space preceding the first and
following the last character in the ruby text. That amount of white
space is normally equal to half the amount of inter-character space of
the ruby text. If the width of the ruby text is at least the width of
the base, then the same type of space distribution applies to the base.
In other words, if the base is shorter than the ruby text, the base is
distribute-space aligned. This type of alignment
is described by [[JLREQ]].
<div class="figure">
<p><img width="145" height="91"
alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is shorter than base"
src="images/ra-ds.gif" /><img width="145" height="91"
alt="Diagram of glyph layout in distribute-space aligned ruby when ruby text is longer than base"
src="images/ra-ds-rb.gif" /></p>
<p><b>Figure 4.2.7</b>: Distribute-space ruby alignment</p>
</div>
</dd>
<!--
<dt><strong>line-edge</strong></dt>
<dd>If the ruby text is not adjacent to a line edge, it is aligned as in
'auto'. If it is adjacent to a line edge, then it is still aligned as in
auto, but the side of the ruby text that touches the end of the line is
lined up with the corresponding edge of the base. This type of alignment
is described by [[JLREQ]]. This type of alignment is
relevant only to the scenario where the ruby text is longer than the
ruby base. In the other scenarios, this is just 'auto'.
<div class="figure">
<p><img class="example" width="146" height="109"
alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base"
src="images/ra-le-l.gif" /><img class="example" width="146"
height="110"
alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base"
src="images/ra-le-r.gif" /></p>
<p><b>Figure 4.2.8</b>: Line edge ruby alignment</p>
</div>
</dd>
-->
</dl>
<p>For a complex ruby with spanning elements, one additional consideration is
required. If the spanning element spans multiple 'rows' (other rbc or rtc
elements), and the ruby alignment requires space distribution among the
'spanned' elements, a ratio must be determined among the 'columns' of spanned
elements. This ratio is computed by taking into consideration the widest
element within each column.</p>
<h2 id="edge-effects">
Edge Effects</h2>
<h3 id="ruby-overhang">
Overhanging Ruby</h3>
<p>
When <i>ruby annotation box</i> is longer than its corresponding <i>ruby base box</i>,
the <i>ruby annotation box</i> may partially overhang adjacent boxes.
</p>
<p>
This level of the specification does not define
how much the overhang may be allowed, and under what conditions.
</p>
<p>If the ruby text is not allowed to overhang,
then the ruby behaves like a traditional inline box,
i.e. only its own contents are rendered within its boundaries
and adjacent elements do not cross the box boundary:
<div class="figure">
<p><img src="images/ro-n.gif"
alt="Diagram showing the ruby boxes interacting with adjacent text">
<p class="caption">Simple ruby whose text is not allowed to overhang adjacent text
</div>
<p>However, if <i>ruby annotation</i> content is allowed to overhang adjacent elements
and it happens to be wider than its base,
then the adjacent content is partially rendered within the area of the <i>ruby container box</i>,
while the <i>ruby annotation</i> may partially overlap the upper blank parts of the adjacent content:
<div class="figure">
<p><img src="images/ro-a.gif"
alt="Diagram showing the ruby boxes interacting with adjacent text">
<p class="caption">Simple ruby whose text is allowed to overhang adjacent text
</div>
<p>The <i>ruby annotations</i> related to a <i>ruby base</i>
must never overhang another <i>ruby base</i>.
<p>The alignment of the contents of the base or the ruby text
is not affected by overhanging behavior.
The alignment is achieved the same way regardless of the overhang behavior setting
and it is computed before the space available for overlap is determined.
It is controlled by the 'ruby-align' property.
<p>This entire logic applies the same way in vertical ideographic layout,
only the dimension in which it works in such a layout is vertical,
instead of horizontal.
<div class="example">
<p>
The user agent may use [[JIS4051]] recommendation of
using one ruby text character length as the maximum overhang length.
Detailed rules for how ruby text can overhang adjacent characters for Japanese are described by [[JLREQ]].
</p>
</div>
<h3 id="line-edge">
Line-edge Alignment</h3>
<p>
When a <i>ruby annotation box</i> that is longer than its <i>ruby base</i>
is at the start or end edge of a line,
the user agent <em>may</em> force the side of the <i>ruby annotation</i> that touches the edge of the line
to align to the corresponding edge of the base.
This type of alignment is described by [[JLREQ]].
</p>
<p>
This level of the specification does not provide a mechanism to control this behavior.
</p>
<div class="figure">
<p><img src="images/ra-le-l.gif"
alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is shorter than base">
<img src="images/ra-le-r.gif"
alt="Diagram of glyph layout in line-edge aligned ruby when ruby text is longer than base">
<p class="caption">Line-edge alignment
</div>
<!--
<h3 id="rubyover">
Ruby overhanging: the 'ruby-overhang' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>ruby-overhang</dfn>
<tr>
<th>Value:
<td>auto | start | end | none
<tr>
<th>Initial:
<td>none
<tr>
<th>Applies to:
<td>the parent of elements with display: ruby-text
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>