-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
2511 lines (1956 loc) · 99.6 KB
/
Overview.html
File metadata and controls
2511 lines (1956 loc) · 99.6 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
<!DOCTYPE html>
<!--
Issues:
bidi
box layout/sizing
clean up inter-character vs. parallel layout requirements
Redo all examples with consistent font. (M+ 2p?)
-->
<html lang=en>
<head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Ruby Module Level 1</title>
<!--
<link href="http://purl.org/dc/terms/" rel="schema.dcterms">
<link href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright" rel="dcterms.rights">
-->
<meta content="CSS Ruby Module Level 1" name=dcterms.title>
<meta content=text name=dcterms.type>
<meta content=2013-09-13 name=dcterms.date>
<meta content="Elika J. Etemad" name=dcterms.creator>
<meta content="Koji Ishii" name=dcterms.creator>
<meta content="Richard Ishida" name=dcterms.creator>
<meta content=W3C name=dcterms.publisher>
<meta content="http://dev.w3.org/csswg/css3-ruby/" name=dcterms.identifier>
<link href="#contents" rel=contents>
<link href="#index" rel=index>
<link href="../default.css" rel=stylesheet type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<body class=h-entry>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1 class=p-name>CSS Ruby Module Level 1</h1>
<h2 class="no-num no-toc" id=longstatus-date->Editor's Draft <time
class=dt-updated datetime=20130913>13 September 2013</time>
<!-- for HTML4 doctype: <span class="value-title" title="20130913">13 September 2013</span></span> --></h2>
<dl>
<dt>This version:
<dd><a class=u-url
href="http://dev.w3.org/csswg/css3-ruby/">http://dev.w3.org/csswg/css3-ruby/</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-ruby/">http://www.w3.org/TR/css3-ruby/</a>
<dt>Editor's draft:
<dd><a
href="http://dev.w3.org/csswg/css3-ruby/">http://dev.w3.org/csswg/css3-ruby/</a>
(<a
href="https://dvcs.w3.org/hg/csswg/log/tip/css3-ruby/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:
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/FIXME"
rel=issues>http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
<dt>Feedback:
<dd><a
href="mailto:www-style@w3.org?subject=%5BSHORTNAME%5D%20feedback">www-style@w3.org</a>
with subject line “<kbd>[css3-ruby] <var>… message topic
…</var></kbd>” (<a
href="http://lists.w3.org/Archives/Public/www-style/"
rel=discussion>archives</a>)
<dt>Editors:
<dd class="p-author h-card vcard"> <a class="p-name fn u-url url"
href="http://fantasai.inkedblade.net/contact" rel=author>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"
href="mailto:koji.a.ishii@mail.rakuten.com" rel=author>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"
href="mailto:ishida@w3.org" rel=author>Richard Ishida</a>, <span
class="p-org org">W3C</span>
<dt>Former editors:
<dd>Michel Suignard, Microsoft
<dd>Marcin Sawicki, Microsoft
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2013 <a href="http://www.w3.org/"><abbr
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><abbr
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
href="http://www.ercim.eu/"><abbr
title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>, <a
href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-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>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcss3-ruby%5D%20PUT%20SUBJECT%20HERE">
www-style@w3.org</a> (see <a
href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
discussion of this specification. When sending e-mail, please put the text
“css3-ruby” in the subject, preferably like this:
“[<!---->css3-ruby<!---->] <em>…summary of comment…</em>”
<p>This document was produced by the <a
href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of
the <a href="http://www.w3.org/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<!--end-status-->
<p>The following features are at risk: …
<h2 class="no-num no-toc" id=contents> Table of Contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#intro"><span class=secno>1. </span> Introduction</a>
<ul class=toc>
<li><a href="#placement"><span class=secno>1.1. </span> Module
interactions</a>
<li><a href="#values"><span class=secno>1.2. </span> Values</a>
<li><a href="#diagram-conventions"><span class=secno>1.3. </span>
Diagram conventions</a>
<li><a href="#ruby-def"><span class=secno>1.4. </span> What is ruby?</a>
</ul>
<li><a href="#ruby-model"><span class=secno>2. </span> Ruby Formatting
Model</a>
<ul class=toc>
<li><a href="#ruby-display"><span class=secno>2.1. </span> Ruby-specific
‘<code class=property>display</code>’ property values</a>
<li><a href="#box-fixup"><span class=secno>2.2. </span> Anonymous Ruby
Box Generation</a>
<li><a href="#pairing"><span class=secno>2.3. </span> Ruby Pairing and
Annotation Levels</a>
<ul class=toc>
<li><a href="#nested-pairing"><span class=secno>2.3.1. </span> Nested
Ruby</a>
</ul>
<li><a href="#autohide"><span class=secno>2.4. </span> Autohiding
Annotations</a>
<li><a href="#white-space"><span class=secno>2.5. </span> White
Space</a>
<li><a href="#ruby-layout"><span class=secno>2.6. </span> Ruby
layout</a>
<ul class=toc>
<li><a href="#inter-character-layout"><span class=secno>2.6.1. </span>
Inter-character ruby layout</a>
</ul>
<li><a href="#box-style"><span class=secno>2.7. </span> Styling Ruby
Boxes</a>
<li><a href="#line-breaks"><span class=secno>2.8. </span> Ruby box and
line breaking</a>
<ul class=toc>
<li><a href="#break-between"><span class=secno>2.8.1. </span> Breaking
between bases</a>
<li><a href="#break-within"><span class=secno>2.8.2. </span> Breaking
within bases</a>
</ul>
<li><a href="#ruby-bidi"><span class=secno>2.9. </span> Bidi
Reordering</a>
<li><a href="#line-height"><span class=secno>2.10. </span> Ruby box and
line stacking</a>
</ul>
<li><a href="#ruby-props"><span class=secno>3. </span> Ruby Properties</a>
<ul class=toc>
<li><a href="#rubypos"><span class=secno>3.1. </span> Ruby positioning:
the ‘<code class=property>ruby-position</code>’ property</a>
<li><a href="#collapsed-ruby"><span class=secno>3.2. </span> Collapsed
Ruby Annotations: the ‘<code class=property>ruby-merge</code>’
property</a>
<li><a href="#ruby-align-property"><span class=secno>3.3. </span> Ruby
Text Distribution: the ‘<code class=property>ruby-align</code>’
property</a>
</ul>
<li><a href="#edge-effects"><span class=secno>4. </span> Edge Effects</a>
<ul class=toc>
<li><a href="#ruby-overhang"><span class=secno>4.1. </span> Overhanging
Ruby</a>
<li><a href="#line-edge"><span class=secno>4.2. </span> Line-edge
Alignment</a>
</ul>
<li class=no-num><a href="#default-stylesheet"> Appendix A: Default Style
Sheet</a>
<ul class=toc>
<li class=no-num><a href="#default-ua-ruby"> Supporting Ruby Layout</a>
<li class=no-num><a href="#default-inline"> Inlining Ruby
Annotations</a>
<li class=no-num><a href="#default-parens"> Generating Parentheses</a>
</ul>
<li><a href="#glossary"><span class=secno>5. </span> Glossary</a>
<li><a href="#conformance"><span class=secno>6. </span> Conformance</a>
<ul class=toc>
<li><a href="#conventions"><span class=secno>6.1. </span> Document
conventions</a>
<li><a href="#conformance-classes"><span class=secno>6.2. </span>
Conformance classes</a>
<li><a href="#partial"><span class=secno>6.3. </span> Partial
implementations</a>
<li><a href="#experimental"><span class=secno>6.4. </span> Experimental
implementations</a>
<li><a href="#testing"><span class=secno>6.5. </span> Non-experimental
implementations</a>
</ul>
<li class=no-num><a href="#acknowledgments"> Acknowledgments</a>
<li class=no-num><a href="#changes"> Changes</a>
<li class=no-num><a href="#references"> References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references"> Normative
references</a>
<li class=no-num><a href="#other-references"> Other references</a>
</ul>
<li class=no-num><a href="#index"> Index</a>
<li class=no-num><a href="#property-index"> Property index</a>
</ul>
<!--end-toc-->
<h2 id=intro><span class=secno>1. </span> Introduction</h2>
<p><em>This section is not normative.</em>
<h3 id=placement><span class=secno>1.1. </span> Module interactions</h3>
<p>This module extends the inline box model of CSS Level 2 <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a> 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><span class=secno>1.2. </span> 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 <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a
href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>. Other CSS
modules may expand the definitions of these value types: for example <a
href="#CSS3VAL" rel=biblioentry>[CSS3VAL]<!--{{CSS3VAL}}--></a>, when
combined with this module, expands the definition of the
<var><length></var> value type as used in this specification.
<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=diagram-conventions><span class=secno>1.3. </span> Diagram
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" height=39
src="images/fullwidth.gif" width=39>
<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" height=39
src="images/halfwidth.gif" width=19>
<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><span class=secno>1.4. </span> What is ruby?</h3>
<p><dfn id=ruby>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 alt="Example of ruby applied on top of a Japanese expression"
src="images/licence.png">
<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
alt="Example showing complex ruby with annotation text over and under the base characters"
src="images/ruby-univ.gif">
<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><a href="#ruby"><i>Ruby</i></a> formatting as used in Japanese is
described in JIS X-4051 <a href="#JIS4051"
rel=biblioentry>[JIS4051]<!--{{JIS4051}}--></a> (in Japanese) and in
Requirements for Japanese Text Layout <a href="#JLREQ"
rel=biblioentry>[JLREQ]<!--{{JLREQ}}--></a> (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><span class=secno>2. </span> 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> <a href="#RUBY"
rel=biblioentry>[RUBY]<!--{{RUBY}}--></a>. In this model, a ruby structure
consists of one or more <dfn id=ruby-base>ruby base</dfn> elements
representing the base (annotated) text, associated with one or more levels
of <dfn id=ruby-annotation>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 <a href="#ruby-base-box"><i>ruby base</i></a> and its
corresponding <a href="#ruby-annotation-box"><i>ruby annotations</i></a>).
<p>Consecutive bases and annotations are grouped together into <dfn
id=ruby-segments>ruby segments</dfn>. Within a <i>ruby segment</i>, a <a
href="#ruby-annotation-box"><i>ruby annotation</i></a> may span multiple
<a href="#ruby-base-box"><i>ruby bases</i></a>.
<p class=note>In HTML, a single <code><ruby></code> element may
contain multiple <a href="#ruby-segments"><i>ruby segments</i></a>. (In
the XHTML Ruby model, a single <code><ruby></code> element can only
contain one <i>ruby segment</i>.)
<h3 id=ruby-display><span class=secno>2.1. </span> Ruby-specific ‘<code
class=property>display</code>’ 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 ‘<code
class=property>display</code>’ property.
<table class=propdef>
<tbody>
<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 ‘<code class=property>display</code>’ values
assign ruby layout roles to an arbitrary element:
<dl>
<dt>‘<a href="#ruby"><code class=css>ruby</code></a>’
<dd>Specifies that an element generates a <dfn id=ruby-container-box
title="ruby container | ruby container box">ruby container box</dfn>.
(Corresponds to HTML/XHTML <code><ruby></code> elements.)
<dt>‘<code class=css>ruby-base</code>’
<dd>Specifies that an element generates a <dfn id=ruby-base-box
title="ruby base box | ruby base">ruby base box</dfn>. (Corresponds to
HTML/XHTML <code><rb></code> elements.)
<dt>‘<code class=css>ruby-text</code>’
<dd>Specifies that an element generates a <dfn id=ruby-annotation-box
title="ruby annotation box | ruby annotation">ruby annotation box</dfn>.
(Corresponds to HTML/XHTML <code><rt></code> elements.)
<dt>‘<code class=css>ruby-base-container</code>’
<dd>Specifies that an element generates a <dfn id=ruby-base-container-box
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>‘<code class=css>ruby-text-container</code>’
<dd>Specifies that an element generates a <dfn
id=ruby-annotation-container-box
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><span class=secno>2.2. </span> 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>. <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>
<ol>
<li>Any in-flow block-level boxes directly contained by a <a
href="#ruby-container-box"><i>ruby container</i></a>, <a
href="#ruby-base-container-box"><i>ruby base container</i></a>, <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, <a href="#ruby-base-box"><i>ruby base box</i></a>, or
<a href="#ruby-annotation-box"><i>ruby annotation box</i></a> are forced
to be inline-level boxes, and their ‘<code
class=property>display</code>’ value computed accordingly. For example,
the ‘<code class=property>display</code>’ property of an in-flow
element with ‘<code class=css>display: block</code>’ parented by an
element with ‘<code class=css>display: ruby-text</code>’ computes to
‘<code class=css>inline-block</code>’. This computation occurs after
any intermediary anonymous-box fixup (such as that required by internal
table elements).
<li>Any consecutive sequence of <a href="#ruby-base-box"><i>ruby
bases</i></a> not parented by a <a
href="#ruby-base-container-box"><i>ruby base container</i></a> is wrapped
in an anonymous <a href="#ruby-base-container-box"><i>ruby base
container</i></a>. Similarly, any consecutive sequence of <a
href="#ruby-annotation-box"><i>ruby annotations</i></a> not parented by a
<a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a> is wrapped in an anonymous <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>.
<li>Within each <a href="#ruby-base-container-box"><i>ruby base
container</i></a>, each sequence of inline-level boxes is wrapped in an
anonymous <a href="#ruby-base-box"><i>ruby base box</i></a>. Similarly,
within each <a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, each sequence of inline-level boxes is wrapped in an
anonymous <a href="#ruby-annotation-box"><i>ruby annotation box</i></a>.
<li>A sequence of <a href="#ruby-base-container-box"><i>ruby base
containers</i></a> and/or <a
href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> not parented by a <a
href="#ruby-container-box"><i>ruby container</i></a> is wrapped in an
anonymous <a href="#ruby-container-box"><i>ruby container</i></a>.
</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><span class=secno>2.3. </span> Ruby Pairing and Annotation
Levels</h3>
<p>Within a ruby structure, each <a href="#ruby-base-box"><i>ruby
base</i></a> is associated with <a href="#ruby-annotation-box"><i>ruby
annotations</i></a> and vice versa. A <a href="#ruby-base-box"><i>ruby
base</i></a> can be associated with at most one <a
href="#ruby-annotation-box"><i>ruby annotation</i></a> per annotation
level. If there are multiple annotation levels, it can therefore be
associated with multiple <a href="#ruby-annotation-box"><i>ruby
annotations</i></a>. A <a href="#ruby-annotation-box"><i>ruby
annotation</i></a> is associated with one or more <a
href="#ruby-base-box"><i>ruby bases</i></a>; annotations can span multiple
bases.
<p><dfn id=annotation-pairing>Annotation pairing</dfn> is the process of
associating <a href="#ruby-annotation-box"><i>ruby annotations</i></a>
with <a href="#ruby-base-box"><i>ruby bases</i></a>.
<ol>
<li>
<p>First, the ruby structure is divided into <a
href="#ruby-segments"><i>ruby segments</i></a>, each consisting of a
single <a href="#ruby-base-container-box"><i>ruby base container</i></a>
followed by one or more <a href="#ruby-annotation-container-box"><i>ruby
annotation containers</i></a>. If the first child of a <a
href="#ruby-container-box"><i>ruby container</i></a> is a <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, an anonymous, empty <a
href="#ruby-base-container-box"><i>ruby base container</i></a> is
assumed to exist before it. Similarly, if the <a
href="#ruby-container-box"><i>ruby container</i></a> contains
consecutive <a href="#ruby-base-container-box"><i>ruby base
containers</i></a>, anonymous, empty <a
href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> are assumed to exist between them. The <a
href="#ruby-base-container-box"><i>ruby base container</i></a> in each
segment is thus associated with each of the <a
href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> in that segment.
<p>Each <a href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a> in a <i>ruby segment</i> represents one <dfn id=level
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 <a href="#ruby-base-box"><i>ruby
base box</i></a> in the <a href="#ruby-base-container-box"><i>ruby base
container</i></a> is paired with one <a
href="#ruby-annotation-box"><i>ruby annotation box</i></a> from each <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a> in its <i>ruby segment</i>. If there are not enough <a
href="#ruby-annotation-box"><i>ruby annotations</i></a> in a <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, the last one is associated with any excess <a
href="#ruby-base-box"><i>ruby bases</i></a>. (If there are not any in the
<a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>, an anonymous empty one is assumed to exist.) If there
are not enough <a href="#ruby-base-box"><i>ruby bases</i></a>, any
remaining <a href="#ruby-annotation-box"><i>ruby annotations</i></a> are
assumed to be associated with empty, anonymous bases inserted at the end
of the <a href="#ruby-base-container-box"><i>ruby base container</i></a>.
<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 <a href="#ruby-base-box"><i>ruby base</i></a> and associated with
one <a href="#ruby-annotation-box"><i>ruby annotation</i></a> (possibly an
empty, anonymous one) from each <a href="#level"><i>annotation
level</i></a>.
<h4 id=nested-pairing><span class=secno>2.3.1. </span> Nested Ruby</h4>
<p>When <a href="#ruby-container-box"><i>ruby containers</i></a> are
nested, pairing begins with the deepest <a
href="#ruby-container-box"><i>ruby container</i></a>, then expands out,
treating each <a href="#ruby-container-box"><i>ruby container</i></a>
nested within another <a href="#ruby-container-box"><i>ruby
container</i></a> essentially as a single <a href="#ruby-base-box"><i>ruby
base</i></a> in the outer <a href="#ruby-container-box"><i>ruby
container</i></a>, and associating each <a
href="#ruby-annotation-box"><i>ruby annotation</i></a> paired with the
nested <a href="#ruby-container-box"><i>ruby container</i></a> as being
associated with (spanning) all of its <a href="#ruby-base-box"><i>ruby
bases</i></a>.
<p>Using nested <a href="#ruby-container-box"><i>ruby containers</i></a>
thus allows the representation of complex spanning relationships.
<p class=issue>This has to be Level 1 because HTML5 allows it, so we have
to handle it. Yay HTML5.
<h3 id=autohide><span class=secno>2.4. </span> Autohiding Annotations</h3>
<p>If a <a href="#ruby-annotation-box"><i>ruby annotation</i></a> has the
exact same text content as its base, it is <dfn id=hidden
title="hidden ruby annotation | hidden annotation">hidden</dfn>. Hiding a
<a href="#ruby-annotation-box"><i>ruby annotation</i></a> does not affect
annotation pairing or the block-axis positioning of boxes in other <a
href="#level"><i>levels</i></a>. However the <a href="#hidden"><i>hidden
annotation</i></a> is not visible, and it has no impact on layout other
than to separate adjacent sequences of <a
href="#ruby-annotation-box"><i>ruby annotation boxes</i></a> within its
level, as if they belonged to separate segments and the <a
href="#hidden"><i>hidden annotation</i></a>’s base were not a <a
href="#ruby-base-box"><i>ruby base</i></a> but an intervening inline.
<div class=example>
<p>This is to allow correct inlined display of annotations for Japanese
words that are a mix of kanji and hirangana. For example, the word
<i>振り仮名</i> should be inlined as
<p class=figure>振り仮名(ふりがな)
<p>and therefore marked up as
<pre>
<!-- --><ruby>
<!-- --> <rb>振</rb><rb>り</rb><rb>仮</rb><rb>名</rb>
<!-- --> <rp>(</rp><rt>ふ</rt><rt>り</rt><rt>が</rt><rt>な</rt><rp>)</rp>
<!-- --><ruby></pre>
<p>However, when displayed as ruby, the “り” should be hidden
<div class=figure>
<p><img
alt="Hiragana annotations for 振り仮名 appear, each above its base character."
src="images/furigana-separate.png">
<p class=caption>Hiragana ruby for 振り仮名
</div>
</div>
<p class=note> Future levels of CSS Ruby may add controls for this, but in
this level it is always forced.
<p>The content comparison for this auto-hiding behavior takes place prior
to white space collapsing and ignores elements (considers only the
<code>textContent</code> of the boxes).
<p class=issue>Is before or after white space collapsing easier? We should
do whatever is easier, as it really doesn't matter much which way to go.
<h3 id=white-space><span class=secno>2.5. </span> White Space</h3>
<p><i>Collapsible</i> white space within a ruby structure is discarded
<ul>
<li>at the beginning and end of a <a href="#ruby-container-box"><i>ruby
container</i></a>, <a href="#ruby-annotation-container-box"><i>ruby
annotation container</i></a>, or <a
href="#ruby-base-container-box"><i>ruby base container</i></a>,
<li>at the beginning/end of a <a href="#ruby-annotation-box"><i>ruby
annotation box</i></a> or <a href="#ruby-base-box"><i>ruby base
box</i></a> if white space is not its only contents,
<li>between a <a href="#ruby-base-container-box"><i>ruby base
container</i></a> and its following <a
href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a>,
<li>between <a href="#ruby-annotation-container-box"><i>ruby annotation
containers</i></a>.
</ul>
<p>Between <a href="#ruby-segments"><i>ruby segments</i></a>, between <a
href="#ruby-base-box"><i>ruby bases</i></a>, and between <a
href="#ruby-annotation-box"><i>ruby annotations</i></a>, however, white
space is not discarded.
<p>Where undiscarded 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>. <a href="#CSS3TEXT"
rel=biblioentry>[CSS3TEXT]<!--{{!CSS3TEXT}}--></a> For <i>collapsible</i>
white space between <a href="#ruby-segments"><i>ruby segments</i></a>,
however, the contextual text for determining collapsing behavior is given
by the <a href="#ruby-base-box"><i>ruby bases</i></a> 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, white space that does not contain a <i>segment break</i> does
not collapse completely away, so this markup will display with a space
between the first and second ruby pairs:
<pre>
<!-- --><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 <a href="#ruby-base-container-box"><i>ruby base container</i></a>
(if between <a href="#ruby-base-box"><i>ruby bases</i></a>), <a
href="#ruby-annotation-container-box"><i>ruby annotation container</i></a>
(if between <a href="#ruby-annotation-box"><i>ruby annotations</i></a>),
or <a href="#ruby-container-box"><i>ruby container</i></a> (if between <a
href="#ruby-segments"><i>ruby segments</i></a>). In the latter case, the
text is considered part of the <i>base level</i>. Such anonynmous boxes do
not take part in pairing. They merely ensure separation between adjacent
bases/annotations.
<p class=issue>Specify how these anonymous white space boxes impact layout.
<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>
<h3 id=ruby-layout><span class=secno>2.6. </span> Ruby layout</h3>
<p>When a ruby structure is laid out, its base level is laid out on the
line, aligned according to its ‘<code
class=property>vertical-align</code>’ property exactly as if its
<i>bases</i> were a regular sequence of <i>inline</i> boxes. Each <a
href="#ruby-base-container-box"><i>ruby base container</i></a> is sized
and positioned to contain exactly the full height of its <a
href="#ruby-base-box"><i>ruby bases</i></a>.
<p><a href="#ruby-annotation-box"><i>Ruby annotations</i></a> associated
with the base level are then positioned with respect to their <a
href="#ruby-base-box"><i>ruby base boxes</i></a> according to the
applicable ‘<a href="#ruby-position"><code
class=property>ruby-position</code></a>’ values. <a
href="#ruby-annotation-box"><i>Ruby annotations</i></a> within a level
(within a single <a href="#ruby-container-box"><i>ruby container</i></a>)
are aligned to each other as if they were inline boxes participating in
the same inline formatting context. Each <a
href="#ruby-annotation-container-box"><i>ruby annotation container</i></a>
is sized and positioned to contain exactly the full height of its <a
href="#ruby-annotation-box"><i>ruby annotations</i></a>.
<p>A ruby container (or fragment thereof) measures as wide as the content
of its widest level. Similarly, <a href="#ruby-base-box"><i>ruby base
boxes</i></a> and <a href="#ruby-annotation-box"><i>ruby annotation
boxes</i></a> within a ruby “column” have the measure of the widest
content in that “column”. In the case of spanning <i>annotations</i>
(whether actually spanning or pretending to span per ‘<code
class=property>ruby-collapse</code>’), the measures of the <a
href="#ruby-annotation-box"><i>ruby annotation box</i></a> and the sum of
its associated <a href="#ruby-base-box"><i>ruby base boxes</i></a> must
match.
<p>How the extra space is distributed when ruby content is narrower than
the measure of its box is specified by the ‘<a href="#ruby-align"><code
class=property>ruby-align</code></a>’ property.
<h4 id=inter-character-layout><span class=secno>2.6.1. </span>
Inter-character ruby layout</h4>
<p>Inter-character annotations have special layout. When ‘<a
href="#ruby-position"><code class=property>ruby-position</code></a>’
indicates ‘<code class=css>inter-character</code>’ annotations, the
affected <i>annotation boxes</i> are spliced into and measured as part of
the layout of the base level. The <a
href="#ruby-base-container-box"><i>ruby base container</i></a> must be
sized to include both the <i>base boxes</i> as well as the ‘<code
class=css>inter-character</code>’ <i>annotation boxes</i>. The affected
<a href="#ruby-annotation-container-box"><i>ruby annotation
container</i></a> is similarly sized so that its content box coincides
with that of the <a href="#ruby-base-container-box"><i>ruby base
container</i></a>.
<p>For the purpose of laying out other levels of annotations, an ‘<code
class=css>inter-character</code>’ annotation effectively becomes part of
its base. <span class=issue>Or should it become a quasi-base between two
bases?</span> A spanning ‘<code class=css>inter-character</code>’
annotation is placed after all the bases that it spans.
<h3 id=box-style><span class=secno>2.7. </span> Styling Ruby Boxes</h3>
<p>In most respects, ruby boxes can be styled similar to inline boxes.
However, the UA is not required to support any of the box properties
(borders, margins, padding), any of the background properties or outline
properties, or any other property that illustrates the bounds of the box
on <a href="#ruby-base-container-box"><i>ruby base container
boxes</i></a>, <a href="#ruby-annotation-container-box"><i>ruby annotation
container boxes</i></a>, or <a href="#nested-pairing">ruby-internal
<i>ruby container boxes</i></a>. The UA may implement these boxes simply
as abstractions for inheritance and control over the layout of their
contents.
<p class=issue> Alternatively... use margins to control offsets? Or could
line-height be adequate? Its centering behavior can be awkward.
<h3 id=line-breaks><span class=secno>2.8. </span> Ruby box and line
breaking</h3>
<p>When there is not enough space for an entire <a
href="#ruby-container-box"><i>ruby container</i></a> to fit on the line,
the ruby may be broken wherever all levels simultaneously allow a break.
Ruby most often breaks between base-annotation sets, but if the
line-breaking rules allow it, can also break within a <a
href="#ruby-base-box"><i>ruby base</i></a> (and, in parallel, its
associated <i>annotation boxes</i>).
<p>Whenever ruby breaks across lines, <a
href="#ruby-annotation-box"><i>ruby annotations</i></a> must stay with
their respective <i>bases</i>. The line <em>must not</em> break between a
<a href="#ruby-base-box"><i>ruby base</i></a> and its <i>annotations</i>,
even in the case of ‘<code class=css>inter-character</code>’
<i>annotations</i>.
<div class=figure> <img
alt="Diagram showing the line breaking opportunity in a "Bopomofo" ruby"
src="images/r-break-b.gif">
<p class=caption>‘<code class=css>inter-character</code>’ ruby line
breaking opportunity
</div>
<h4 id=break-between><span class=secno>2.8.1. </span> Breaking between
bases</h4>
<p>In typical cases, <a href="#ruby-base-box"><i>ruby base boxes</i></a>
and <a href="#ruby-annotation-box"><i>ruby annotation boxes</i></a> are
styled to forbid internal line wrapping and do not contain forced breaks.
(See <a href="#default-stylesheet">Appendix A</a>.) In such cases the <a
href="#ruby-container-box"><i>ruby container</i></a> can only break
between adjacent <a href="#ruby-base-box"><i>ruby bases</i></a>, and only
if no <a href="#ruby-annotation-box"><i>ruby annotations</i></a> span
those <a href="#ruby-base-box"><i>ruby bases</i></a>.
<div class=figure>
<p><img
alt="Diagram showing the line breaking opportunity in a complex ruby"
src="images/r-break-a.gif">
<p class=caption>Ruby line breaking opportunity
</div>
<p>Whether ruby can break between two adjacent <a
href="#ruby-base-box"><i>ruby bases</i></a> is controlled by normal
line-breaking rules for the base text, exactly as if the <a
href="#ruby-base-box"><i>ruby bases</i></a> were adjacent <i>inline</i>
boxes. (The annotations are ignored when determining soft wrap
opportunities for the base level.)
<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 ‘<code
class=property>word-break</code>’ is ‘<code
class=css>keep-all</code>’, that line break is forbidden.
<pre><ruby>蝴<rt>hú</rt>蝶<rt>dié</rt></pre>
</div>
<p>Inter-base white space is significant for evaluating line break
opportunities between <a href="#ruby-base-box"><i>ruby bases</i></a>. As
with white space between inlines, it collapses when the line breaks there.
Similarly, annotation white space is also trimmed at a line break.
<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—and the space between “1” and
“2”—disappears, in accordance with standard CSS white space
processing rules. <a href="#CSS3TEXT"
rel=biblioentry>[CSS3TEXT]<!--{{CSS3TEXT}}--></a>
</div>
<h4 id=break-within><span class=secno>2.8.2. </span> Breaking within bases</h4>
<p>For longer base texts, it is sometimes appropriate to allow breaking
within a base-annotation pair. For example, if an English sentence is
annotated with its Japanese translation, allowing the text to wrap allows
for reasonable line breaking behavior in the paragraph.
<p class=issue> Insert scanned example so people don't think this is just
the ramblings of an insane spec-writer.
<p>Line-breaking within a <a href="#ruby-base-box"><i>ruby base</i></a> is
only allowed if the ‘<code class=property>white-space</code>’ property
of the <a href="#ruby-base-box"><i>ruby base</i></a> and all its parallel
<i>annotations</i> allow it, and there exists a <i>soft wrap
opportunity</i> <em>within</em> (i.e. not at the start or end) the content
of each base/annotation box. Since there is no structural correspondance
between fragments of content within <a href="#ruby-base-box"><i>ruby
bases</i></a> and <i>annotations</i>, the UA may break at any set of
opportunities; but it is recommended that the UA attempt to proportionally
balance the amount of content inside each fragment.