-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.html
1681 lines (1427 loc) · 116 KB
/
Overview.html
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><html lang=en><head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Ruby Layout Module Level 1</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
</head>
<body class=h-entry>
<div class=head>
<p data-fill-with=logo><a class=logo href=http://www.w3.org/>
<img alt=W3C height=48 src=https://www.w3.org/Icons/w3c_home width=72>
</a>
</p>
<h1 class="p-name no-ref" id=title>CSS Ruby Layout Module Level 1</h1>
<h2 class="no-num no-toc no-ref heading settled" id=subtitle><span class=content>Editor’s Draft,
<time class=dt-updated datetime=20141216>16 December 2014</time></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-ruby-1/>http://dev.w3.org/csswg/css-ruby-1/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css-ruby-1/>http://www.w3.org/TR/css-ruby-1/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2013/WD-css3-ruby-20130919/ rel=previous>http://www.w3.org/TR/2013/WD-css3-ruby-20130919/</a><dt>Feedback:<dd><span><a href="mailto:www-style@w3.org?subject=%5Bcss-ruby%5D%20feedback">www-style@w3.org</a> with subject line “<kbd>[css-ruby] <var>… message topic …</var></kbd>” (<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)</span><dt>Issue Tracking:<dd><a href=#issues-index>Inline In Spec</a><dt class=editor>Editors:<dd class=editor><div class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://fantasai.inkedblade.net/contact>Elika J. Etemad</a> (<span class="p-org org">Invited Expert</span>)</div><dd class=editor><div class="p-author h-card vcard"><span class="p-name fn">Koji Ishii</span> (<span class="p-org org">Google</span>)</div></dl></div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2014 <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>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id=abstract><span class=content>Abstract</span></h2>
<div class=p-summary data-fill-with=abstract><p>“Ruby”, a form of interlinear annotation, are short runs of text alongside the base text.
They are 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.</p>
<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.</div>
<h2 class="no-num no-toc no-ref heading settled" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=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=%5Bcss-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 “css-ruby” in the subject,
preferably like this:
“[css-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>
This document is governed by the <a href=http://www.w3.org/2014/Process-20140801/>1 August 2014 W3C Process Document</a>.
</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents role=navigation><ul class=toc role=directory><li><a href=#intro><span class=secno>1</span> <span class=content>
Introduction</span></a><ul class=toc><li><a href=#placement><span class=secno>1.1</span> <span class=content>
Module interactions</span></a><li><a href=#values><span class=secno>1.2</span> <span class=content>
Values</span></a><li><a href=#diagram-conventions><span class=secno>1.3</span> <span class=content>
Diagram conventions</span></a><li><a href=#ruby-def><span class=secno>1.4</span> <span class=content>
What is ruby?</span></a></ul><li><a href=#ruby-model><span class=secno>2</span> <span class=content>
Ruby Box Model</span></a><ul class=toc><li><a href=#ruby-display><span class=secno>2.1</span> <span class=content>
Ruby-specific <span class=property data-link-type=propdesc title=display>display</span> Values</span></a><ul class=toc><li><a href=#formatting-context><span class=secno>2.1.1</span> <span class=content>
The Ruby Formatting Context</span></a><li><a href=#display-inside-outside><span class=secno>2.1.2</span> <span class=content>
Ruby-specific <span class=property data-link-type=propdesc title=display-inside>display-inside</span> and <span class=property data-link-type=propdesc title=display-outside>display-outside</span> values</span></a><li><a href=#block-ruby><span class=secno>2.1.3</span> <span class=content>
Non-Inline Ruby</span></a></ul><li><a href=#box-fixup><span class=secno>2.2</span> <span class=content>
Anonymous Ruby Box Generation</span></a><li><a href=#ruby-pairing><span class=secno>2.3</span> <span class=content>
Annotation Pairing</span></a><ul class=toc><li><a href=#segment-pairing><span class=secno>2.3.1</span> <span class=content>
Segment Pairing and Annotation Levels</span></a><li><a href=#base-annotation-pairing><span class=secno>2.3.2</span> <span class=content>
Unit Pairing and Spanning Annotations</span></a><li><a href=#nested-pairing><span class=secno>2.3.3</span> <span class=content>
Complex Spanning with Nested Ruby</span></a></ul><li><a href=#autohide><span class=secno>2.4</span> <span class=content>
Autohiding Base-identical Annotations</span></a><li><a href=#white-space><span class=secno>2.5</span> <span class=content>
White Space Collapsing</span></a></ul><li><a href=#ruby-layout><span class=secno>3</span> <span class=content>
Ruby Layout</span></a><ul class=toc><li><a href=#inter-character-layout><span class=secno>3.1</span> <span class=content>
Inter-character Ruby Layout</span></a><li><a href=#box-style><span class=secno>3.2</span> <span class=content>
Styling Ruby Boxes</span></a><li><a href=#line-breaks><span class=secno>3.3</span> <span class=content>
Breaking Across Lines</span></a><ul class=toc><li><a href=#break-between><span class=secno>3.3.1</span> <span class=content>
Breaking Between Bases</span></a><li><a href=#break-within><span class=secno>3.3.2</span> <span class=content>
Breaking Within Bases</span></a></ul><li><a href=#bidi><span class=secno>3.4</span> <span class=content>
Bidi Reordering</span></a><li><a href=#line-height><span class=secno>3.5</span> <span class=content>
Line Spacing</span></a></ul><li><a href=#ruby-props><span class=secno>4</span> <span class=content>
Ruby Formatting Properties</span></a><ul class=toc><li><a href=#rubypos><span class=secno>4.1</span> <span class=content>
Ruby Positioning: the <span class=property data-link-type=propdesc title=ruby-position>ruby-position</span> property</span></a><li><a href=#collapsed-ruby><span class=secno>4.2</span> <span class=content>
Sharing Annotation Space: the <span class=property data-link-type=propdesc title=ruby-merge>ruby-merge</span> property</span></a><li><a href=#ruby-align-property><span class=secno>4.3</span> <span class=content><span></span>
Ruby Text Distribution: the <span class=property data-link-type=propdesc title=ruby-align>ruby-align</span> property</span></a></ul><li><a href=#edge-effects><span class=secno>5</span> <span class=content>
Edge Effects</span></a><ul class=toc><li><a href=#ruby-overhang><span class=secno>5.1</span> <span class=content>
Overhanging Ruby</span></a><li><a href=#line-edge><span class=secno>5.2</span> <span class=content>
Line-edge Alignment</span></a></ul><li><a href=#default-stylesheet><span class=secno></span> <span class=content>
Appendix A: Default Style Sheet</span></a><ul class=toc><li><a href=#default-ua-ruby><span class=secno></span> <span class=content>
<span class=secno>A.1</span> Supporting Ruby Layout</span></a><li><a href=#default-inline><span class=secno></span> <span class=content>
<span class=secno>A.2</span> Inlining Ruby Annotations</span></a><li><a href=#default-parens><span class=secno></span> <span class=content>
<span class=secno>A.3</span> Generating Parentheses</span></a></ul><li><a href=#glossary><span class=secno>6</span> <span class=content>
Glossary</span></a><li><a href=#acknowledgments><span class=secno></span> <span class=content>
Acknowledgments</span></a><li><a href=#changes><span class=secno></span> <span class=content>
Changes</span></a><li><a href=#conformance><span class=secno></span> <span class=content>
Conformance</span></a><ul class=toc><li><a href=#conventions><span class=secno></span> <span class=content>
Document conventions</span></a><li><a href=#conformance-classes><span class=secno></span> <span class=content>
Conformance classes</span></a><li><a href=#partial><span class=secno></span> <span class=content>
Partial implementations</span></a><li><a href=#experimental><span class=secno></span> <span class=content>
Experimental implementations</span></a><li><a href=#testing><span class=secno></span> <span class=content>
Non-experimental implementations</span></a></ul><li><a href=#references><span class=secno></span> <span class=content>References</span></a><ul class=toc><li><a href=#normative><span class=secno></span> <span class=content>Normative References</span></a><li><a href=#informative><span class=secno></span> <span class=content>Informative References</span></a></ul><li><a href=#index><span class=secno></span> <span class=content>Index</span></a><li><a href=#property-index><span class=secno></span> <span class=content>Property Index</span></a><li><a href=#issues-index><span class=secno></span> <span class=content>Issues Index</span></a></ul></div>
<main>
<p></p>
<h2 class="heading settled" data-level=1 id=intro><span class=secno>1. </span><span class=content>
Introduction</span><a class=self-link href=#intro></a></h2>
<p><em>This section is not normative.</em>
<h3 class="heading settled" data-level=1.1 id=placement><span class=secno>1.1. </span><span class=content>
Module interactions</span><a class=self-link href=#placement></a></h3>
<p>This module extends the inline box model of CSS Level 2 <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=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 class="heading settled" data-level=1.2 id=values><span class=secno>1.2. </span><span class=content>
Values</span><a class=self-link href=#values></a></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 data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=CSS21>[CSS21]</a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=CSS21>[CSS21]</a>.
Other CSS modules may expand the definitions of these value types: for
example <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3val title=CSS3VAL>[CSS3VAL]</a>, 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 class="heading settled" data-level=1.3 id=diagram-conventions><span class=secno>1.3. </span><span class=content>
Diagram conventions</span><a class=self-link href=#diagram-conventions></a></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 class="heading settled" data-level=1.4 id=ruby-def><span class=secno>1.4. </span><span class=content>
What is ruby?</span><a class=self-link href=#ruby-def></a></h3>
<p><dfn data-dfn-type=dfn data-noexport="" id=ruby>Ruby<a class=self-link href=#ruby></a></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
<span lang=ja>taigo</span> 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><i>Ruby</i> formatting as used in Japanese is described in JIS X-4051 <a data-biblio-type=informative data-link-type=biblio href=#biblio-jis4051 title=JIS4051>[JIS4051]</a> (in Japanese)
and in Requirements for Japanese Text Layout <a data-biblio-type=informative data-link-type=biblio href=#biblio-jlreq title=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 class="heading settled" data-level=2 id=ruby-model><span class=secno>2. </span><span class=content>
Ruby Box Model</span><a class=self-link href=#ruby-model></a></h2>
<p>The CSS ruby model is based on
the <a href=http://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element>W3C HTML5 Ruby Markup</a> model
and the <a href=http://www.w3.org/TR/ruby/>XHTML Ruby Annotation Recommendation</a> <a data-biblio-type=informative data-link-type=biblio href=#biblio-ruby title=RUBY>[RUBY]</a>.
In this model, a ruby structure consists of
one or more <i>ruby base</i> elements representing the base (annotated) text,
associated with one or more levels of <i>ruby annotation</i> elements representing the annotations.
The structure of ruby is similar to that of a table:
there are “rows” (the <i title="base level">base text level</i>, each <i>annotation level</i>)
and “columns” (each <i>ruby base</i> and its corresponding <i>ruby annotations</i>).
<p>Consecutive bases and annotations are grouped together into <i>ruby segments</i>.
Within a <i>ruby segment</i>, a <i>ruby annotation</i> may span multiple <i>ruby bases</i>.
<p class=note role=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 class="heading settled" data-level=2.1 id=ruby-display><span class=secno>2.1. </span><span class=content>
Ruby-specific <a class=property data-link-type=propdesc href=#propdef-display>display</a> Values</span><a class=self-link href=#ruby-display></a></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 <a class=property data-link-type=propdesc href=#propdef-display>display</a> property.
<table class=propdef>
<tr>
<th>Name:
<td><dfn class=css data-dfn-type=property data-export="" id=propdef-display>display<a class=self-link href=#propdef-display></a></dfn><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 <a class=property data-link-type=propdesc href=#propdef-display>display</a> values assign ruby layout roles to an arbitrary element:
<dl data-dfn-for=display data-dfn-type=value data-export="">
<dt><dfn class=css data-dfn-for=display data-dfn-type=value data-export="" id=valdef-display-ruby><a class=css data-link-type=maybe href=#valdef-display-ruby>ruby</a><a class=self-link href=#valdef-display-ruby></a></dfn>
<dd>Specifies that an element generates a <dfn data-dfn-for="" data-dfn-type=dfn data-export="" id=ruby-container title="ruby container | ruby container box">ruby container box<a class=self-link href=#ruby-container></a></dfn>.
(Corresponds to HTML/XHTML <code><ruby></code> elements.)
<dt><dfn class=css data-dfn-for=display data-dfn-type=value data-export="" id=valdef-display-ruby-base><a class=css data-link-type=maybe href=#valdef-display-ruby-base>ruby-base</a><a class=self-link href=#valdef-display-ruby-base></a></dfn>
<dd>Specifies that an element generates a <dfn data-dfn-for="" data-dfn-type=dfn data-export="" id=ruby-base-box title="ruby base box | ruby base">ruby base box<a class=self-link href=#ruby-base-box></a></dfn>.
(Corresponds to HTML/XHTML <code><rb></code> elements.)
<dt><dfn class=css data-dfn-for=display data-dfn-type=value data-export="" id=valdef-display-ruby-text><a class=css data-link-type=maybe href=#valdef-display-ruby-text>ruby-text</a><a class=self-link href=#valdef-display-ruby-text></a></dfn>
<dd>Specifies that an element generates a <dfn data-dfn-for="" data-dfn-type=dfn data-export="" id=ruby-annotation-box title="ruby annotation box | ruby annotation | annotation">ruby annotation box<a class=self-link href=#ruby-annotation-box></a></dfn>.
(Corresponds to HTML/XHTML <code><rt></code> elements.)
<dt><dfn class=css data-dfn-for=display data-dfn-type=value data-export="" id=valdef-display-ruby-base-container><a class=css data-link-type=maybe href=#valdef-display-ruby-base-container>ruby-base-container</a><a class=self-link href=#valdef-display-ruby-base-container></a></dfn>
<dd>Specifies that an element generates a <dfn data-dfn-for="" data-dfn-type=dfn data-export="" id=ruby-base-container-box title="ruby base container box | ruby base container">ruby base container box<a class=self-link href=#ruby-base-container-box></a></dfn>.
(Corresponds to XHTML <code><rbc></code> elements; generated as an anonymous box in HTML.)
<dt><dfn class=css data-dfn-for=display data-dfn-type=value data-export="" id=valdef-display-ruby-text-container><a class=css data-link-type=maybe href=#valdef-display-ruby-text-container>ruby-text-container</a><a class=self-link href=#valdef-display-ruby-text-container></a></dfn>
<dd>Specifies that an element generates a <dfn data-dfn-for="" data-dfn-type=dfn data-export="" id=ruby-annotation-container-box title="ruby annotation container box | ruby annotation container">ruby annotation container box<a class=self-link href=#ruby-annotation-container-box></a></dfn>.
(Corresponds to HTML/XHTML <code><rtc></code> elements.)
</dl>
<p class=advisement>Authors using a language (such as HTML)
that supports dedicated ruby markup
should use that markup rather than
styling arbitrary elements (like <code><span></code>)
with ruby <a class=property data-link-type=propdesc href=#propdef-display>display</a> values.
Using the correct markup ensures that screen readers
and non-CSS renderers can interpret the ruby structures.
<h4 class="heading settled" data-level=2.1.1 id=formatting-context><span class=secno>2.1.1. </span><span class=content>
The Ruby Formatting Context</span><a class=self-link href=#formatting-context></a></h4>
<p><i>Ruby containers</i> are non-atomic inline-level boxes.
Like inline boxes, they break across lines,
and their containing block is the nearest block container ancestor.
And just as the contents of an inline box
participate in the same inline formatting context that contains the inline box itself,
a <i>ruby container</i> and its base-level contents
participate in the same inline formatting context that contains the <i>ruby container</i> itself.
<p>However <i>ruby containers</i> also establish a <dfn data-dfn-type=dfn data-noexport="" id=ruby-formatting-context>ruby formatting context<a class=self-link href=#ruby-formatting-context></a></dfn>
that builds further structure around their segment of the inline formatting context.
<i>Ruby bases</i>, <i>ruby annotations</i>, <i>ruby base containers</i>, and <i>ruby annotation containers</i>
are <dfn data-dfn-type=dfn data-noexport="" id=internal-ruby-boxes title="internal ruby boxes|internal ruby display types">internal ruby boxes<a class=self-link href=#internal-ruby-boxes></a></dfn>:
like <i>internal table elements</i>,
they have specific roles in ruby layout,
and participate in their <i>ruby container</i>’s <i>ruby formatting context</i>.
<p>As with the contents of inline boxes,
the containing block for the contents of a <i>ruby container</i> (and all its <i>internal ruby boxes</i>)
is the containing block of the <i>ruby container</i>.
So floats, for example, are trapped by the <i>ruby container</i>’s containing block,
not any of the ruby box types.
<p class=issue id=issue-ca88244c><a class=self-link href=#issue-ca88244c></a>Are internal ruby boxes inline-level?
<h4 class="heading settled" data-level=2.1.2 id=display-inside-outside><span class=secno>2.1.2. </span><span class=content>
Ruby-specific <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside>display-inside</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside>display-outside</a> values</span><a class=self-link href=#display-inside-outside></a></h4>
<p>The ruby-specific <a class=property data-link-type=propdesc href=#propdef-display>display</a> values map to <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside>display-inside</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside>display-outside</a> as follows:
<table class=data>
<thead>
<tr><th><a class=property data-link-type=propdesc href=#propdef-display>display</a>
<th><a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside>display-outside</a>
<th><a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside>display-inside</a>
<tbody>
<tr><td><a class=css data-link-type=maybe href=#valdef-display-ruby>ruby</a>
<td><a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-outside-inline-level>inline-level</a>
<td><a class=css data-link-type=maybe href=#valdef-display-ruby>ruby</a>
<tr><td><a class=css data-link-type=maybe href=#valdef-display-ruby-base>ruby-base</a>
<td><a class=css data-link-type=maybe href=#valdef-display-ruby-base>ruby-base</a>
<td><a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-align-3/#valdef-justify-content-align-content-auto>auto</a>
<tr><td><a class=css data-link-type=maybe href=#valdef-display-ruby-text>ruby-text</a>
<td><a class=css data-link-type=maybe href=#valdef-display-ruby-text>ruby-text</a>
<td><a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-align-3/#valdef-justify-content-align-content-auto>auto</a>
<tr><td><a class=css data-link-type=maybe href=#valdef-display-ruby-base-container>ruby-base-container</a>
<td><a class=css data-link-type=maybe href=#valdef-display-ruby-base-container>ruby-base-container</a>
<td><a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-align-3/#valdef-justify-content-align-content-auto>auto</a>
<tr><td><a class=css data-link-type=maybe href=#valdef-display-ruby-text-container>ruby-text-container</a>
<td><a class=css data-link-type=maybe href=#valdef-display-ruby-text-container>ruby-text-container</a>
<td><a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-align-3/#valdef-justify-content-align-content-auto>auto</a>
</table>
<p>See the <a href=http://www.w3.org/TR/css-display/>CSS Display Module</a>
for more information on <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-inside>display-inside</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside>display-outside</a>. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-display title=CSS3-DISPLAY>[CSS3-DISPLAY]</a>
<h4 class="heading settled" data-level=2.1.3 id=block-ruby><span class=secno>2.1.3. </span><span class=content>
Non-Inline Ruby</span><a class=self-link href=#block-ruby></a></h4>
<p>If an element has a computed <i>inner display type</i> of <a class=css data-link-type=maybe href=#valdef-display-ruby>ruby</a>
and a computed computed <i>outer display type</i> other than <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-outside-inline-level>inline-level</a>,
then it generates two boxes:
a principal block container box of the required <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-display-3/#propdef-display-outside>display-outside</a> type,
and an inline-level <i>ruby container</i>.
All properties specified on the element apply to the principal box
(and if inheritable, inherit to the <i>ruby container box</i>).
This allows styling the element as a block,
while correctly maintaining the internal ruby structure.
<p class=note role=note>
Note: There is no dedicated block-level <a class=property data-link-type=propdesc href=#propdef-display>display</a> shorthand keyword
because ruby is fundamentally an inline layout feature.
<p class=note role=note>
Note that absolute positioning or floating an element causes its <a class=property data-link-type=propdesc href=#propdef-display>display</a> value
to compute to a block-level equivalent. (See <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-display title=CSS3-DISPLAY>[CSS3-DISPLAY]</a> or <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=CSS21>[CSS21]</a> section 9.7.)
For the <i>internal ruby display types</i>,
this causes their <a class=property data-link-type=propdesc href=#propdef-display>display</a> value to compute to <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-inside-block>block</a>.
<h3 class="heading settled" data-level=2.2 id=box-fixup><span class=secno>2.2. </span><span class=content>
Anonymous Ruby Box Generation</span><a class=self-link href=#box-fixup></a></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 data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=CSS21>[CSS21]</a>
<ol>
<li id=anon-gen-anon-ruby><a class=self-link href=#anon-gen-anon-ruby></a><strong>Generate anonymous ruby containers</strong>:
Any <a href=http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes>consecutive</a> sequence of
improperly-contained
<i>ruby base containers</i>,
<i>ruby annotation containers</i>,
<i>ruby bases</i>,
and/or
<i>ruby annotations</i>
(and any intervening <i>white space</i>)
is wrapped in an anonymous <i>ruby container</i>.
For the purpose of this step:
<ul>
<li>an improperly-contained <i>ruby base</i> is one not parented by a <i>ruby base container</i> or <i>ruby container</i>
<li>an improperly-contained <i>ruby annotation</i> is one not parented by a <i>ruby annotation container</i> or <i>ruby container</i>
<li>an improperly-contained <i>ruby base container</i> or <i>ruby annotation container</i>
is one not parented by a <i>ruby container</i>
</ul>
<li id=anon-gen-inlinize><a class=self-link href=#anon-gen-inlinize></a><strong>Inlinize block-level boxes:</strong>
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 <a class=property data-link-type=propdesc href=#propdef-display>display</a> value computed accordingly.
For example,
the <a class=property data-link-type=propdesc href=#propdef-display>display</a> property of an in-flow element with <a class=css data-link-type=propdesc href=#propdef-display title=display>display: block</a>
parented by an element with <a class=css data-link-type=propdesc href=#propdef-display title=display>display: ruby-text</a>
computes to <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-display-3/#valdef-display-inline-block>inline-block</a>.
This computation occurs after any intermediary anonymous-box fixup
(such as that required by internal table elements).
<li id=anony-gen-trim-space><a class=self-link href=#anony-gen-trim-space></a><strong>Trim leading/trailing white space:</strong>
Any white space within a ruby structure is discarded
at the beginning and end of
a <i>ruby container</i>, <i>ruby annotation container</i>, or <i>ruby base container</i>.
<li id=anon-gen-bare-inlines><a class=self-link href=#anon-gen-bare-inlines></a><strong>Wrap misparented inline-level content:</strong>
Any consecutive sequence of text and inline-level boxes
directly parented by a <i>ruby container</i> or <i>ruby base container</i>
is wrapped in an anonymous <i>ruby base</i>.
Similarly, any consecutive sequence of text and inline-level boxes
directly parented by a <i>ruby annotation container</i>
is wrapped in an anonymous <i>ruby annotation</i>.
<p>However, if an anonymous box so constructed contains only <i>white space</i>,
it is considered <dfn data-dfn-type=dfn data-noexport="" id=intra-ruby-white-space>intra-ruby white space<a class=self-link href=#intra-ruby-white-space></a></dfn>
and is either discarded as <i>inter-level white space</i>
or preserved as <i>intra-level white space</i>
as described below.</p>
<li id=anon-gen-discard-space><a class=self-link href=#anon-gen-discard-space></a><strong>Remove inter-level white space:</strong>
Any <i>intra-ruby white space</i>
whose immediately adjacent siblings match one of the patterns below
is <dfn data-dfn-type=dfn data-noexport="" id=inter-level-white-space>inter-level white space<a class=self-link href=#inter-level-white-space></a></dfn>
and is removed, as if it had <a class=css data-link-type=propdesc href=#propdef-display title=display>display: none</a>.
<table class=data>
<thead>
<tr><th>Previous box
<th>Next box
<tbody>
<tr><td><var>any</var>
<td><i>ruby annotation container</i>
<tr><td>not <i>ruby annotation</i>
<td><i>ruby annotation</i>
</table>
<li id=anon-gen-interpret-space><a class=self-link href=#anon-gen-interpret-space></a><strong>Interpret intra-level white space:</strong>
Any <i>intra-ruby white space</i> box
whose immediately adjacent siblings match one of the patterns below
is assigned the box type and subtype defined in the table below:
<table class=data>
<colgroup span=2></colgroup>
<colgroup span=2></colgroup>
<thead>
<tr><th>Previous box
<th>Next box
<th>Box type
<th>Subtype
<tbody>
<tr><td><i>ruby base</i>
<td><i>ruby base</i>
<td><i>ruby base</i>
<td><dfn data-dfn-type=dfn data-noexport="" id=inter-base-white-space>inter-base white space<a class=self-link href=#inter-base-white-space></a></dfn>
<tr><td><i>ruby annotation</i>
<td><i>ruby annotation</i>
<td><i>ruby annotation</i>
<td><dfn data-dfn-type=dfn data-noexport="" id=inter-annotation-white-space>inter-annotation white space<a class=self-link href=#inter-annotation-white-space></a></dfn>
<tr><td><i>ruby annotation</i> or <i>ruby annotation container</i>
<td><i>ruby base</i> or <i>ruby base container</i>
<td rowspan=3><i>ruby base</i>
<td rowspan=3><dfn data-dfn-type=dfn data-noexport="" id=inter-segment-white-space>inter-segment white space<a class=self-link href=#inter-segment-white-space></a></dfn>
<tr><td><i>ruby base</i> or <i>ruby base container</i>
<td><i>ruby base container</i>
<tr><td><i>ruby base container</i>
<td><i>ruby base container</i>
</table>
The <dfn data-dfn-type=dfn data-noexport="" id=intra-level-white-space>intra-level white space<a class=self-link href=#intra-level-white-space></a></dfn> boxes defined above are
treated specially for pairing and layout. See below.
<li id=anon-gen-unbreak><a class=self-link href=#anon-gen-unbreak></a><strong>Suppress line breaks:</strong>
Convert all forced line breaks inside <i>ruby annotations</i> (regardless of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-white-space>white-space</a> value)
as defined for <i>collapsible</i> segment breaks in <a href=http://www.w3.org/TR/css-text-3/#line-break-transform>CSS Text Level 3 § 4.1.2</a>.
<p class=issue id=issue-8af70305><a class=self-link href=#issue-8af70305></a>The goal of this is to simplify the layout model by suppressing any line breaks within ruby annotations.
Alternatively we could try to define some kind of acceptable behavior for them.
<li id=anon-gen-anon-containers><a class=self-link href=#anon-gen-anon-containers></a><strong>Generate anonymous level containers:</strong>
Any consecutive sequence of <i>ruby bases</i> and <i>inter-base white space</i>
(and not <i>inter-segment white space</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> and <i>inter-annotation white space</i>
not parented by a <i>ruby annotation container</i>
is wrapped in an anonymous <i>ruby annotation container</i>.
</ol>
<p class=issue id=issue-778a7acd><a class=self-link href=#issue-778a7acd></a>Make <a href=http://lists.w3.org/Archives/Public/www-archive/2014Jun/att-0027/PastedGraphic-1.png>this diagram</a> into an example.
<p>Once all ruby layout structures are properly parented,
the UA can start to associate bases with their annotations.
<p class=note role=note>
Note that the UA is not required to create any of these anonymous boxes
(or the anonymous empty <i>intra-level white space</i> boxes in the pairing section)
in its internal structures,
as long as pairing and layout behaves as if they existed.
<h3 class="heading settled" data-level=2.3 id=ruby-pairing><span class=secno>2.3. </span><span class=content>
Annotation Pairing</span><a class=self-link href=#ruby-pairing></a></h3>
<p>Annotation <dfn data-dfn-type=dfn data-noexport="" id=pairing>pairing<a class=self-link href=#pairing></a></dfn> is the process of associating
<i>ruby annotations</i> with <i>ruby bases</i>.
Each <i>ruby annotation</i> is associated with one or more <i>ruby bases</i>,
and is said to <dfn data-dfn-type=dfn data-noexport="" id=span>span<a class=self-link href=#span></a></dfn> those bases.
(A <i>ruby annotation</i> that <i>spans</i> multiple bases is called
a <dfn data-dfn-type=dfn data-noexport="" id=spanning-annotation>spanning annotation<a class=self-link href=#spanning-annotation></a></dfn>.)
<p>A <i>ruby base</i> is can be associated with
only one <i>ruby annotation</i> per <i>annotation level</i>.
However, if there are multiple <i>annotation levels</i>,
it can be associated with multiple <i>ruby annotations</i>.</p>
<p>Once pairing is complete, ruby “column” units are defined,
each represented by a single <i>ruby base</i>
and one <i>ruby annotation</i> (possibly an empty, anonymous one)
from each <i>annotation level</i> in its <i>ruby segment</i>.</p>
<h4 class="heading settled" data-level=2.3.1 id=segment-pairing><span class=secno>2.3.1. </span><span class=content>
Segment Pairing and Annotation Levels</span><a class=self-link href=#segment-pairing></a></h4>
<p>A ruby structure is divided into <dfn data-dfn-type=dfn data-noexport="" id=ruby-segments>ruby segments<a class=self-link href=#ruby-segments></a></dfn>,
each consisting of a single <i>ruby base container</i>
followed by one or more <i>ruby annotation containers</i>.
Each <i>ruby annotation container</i> in a <i>ruby segment</i>
represents one <dfn data-dfn-type=dfn data-noexport="" id=annotation-level title="annotation level | level">level<a class=self-link href=#annotation-level></a></dfn> of annotation for the base text:
the first one represents the first level of annotation,
the second one represents the second level of annotation,
and so on.
The <i>ruby base container</i> represents the <dfn data-dfn-type=dfn data-noexport="" id=base-level>base level<a class=self-link href=#base-level></a></dfn>.
The <i>ruby base container</i> in each segment is thus paired
with each of the <i>ruby annotation containers</i> in that segment.
<p>In order to handle degenerate cases, some empty anonymous containers are assumed:
<ul>
<li>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.
<li>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.
</ul>
<p><i>Inter-segment white space</i> is effectively a <i>ruby segment</i> of its own.
<h4 class="heading settled" data-level=2.3.2 id=base-annotation-pairing><span class=secno>2.3.2. </span><span class=content>
Unit Pairing and Spanning Annotations</span><a class=self-link href=#base-annotation-pairing></a></h4>
<p>Within a <i>ruby segment</i>,
each <i>ruby base</i> in the <i>ruby base container</i>
is paired with one <i>ruby annotation</i>
from each <i>ruby annotation container</i> in its <i>ruby segment</i>.
<p>If a <i>ruby annotation container</i> contains only
a single, anonymous <i>ruby annotation</i>,
then that <i>ruby annotation</i> is paired with (i.e. <i>spans</i> across)
all of the <i>ruby bases</i> in its <i>ruby segment</i>.
<p>Otherwise, each <i>ruby annotation</i> is paired,
in order, with the corresponding <i>ruby base</i> in that segment.
If there are not enough <i>ruby annotations</i> in a <i>ruby annotation container</i>,
the remaining <i>ruby bases</i> are paired with anonymous empty annotations
inserted at the end of the <i>ruby annotation container</i>.
If there are not enough <i>ruby bases</i>,
any remaining <i>ruby annotations</i> pair 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 <i>spanning annotations</i>
to their bases appropriately.
<p><i>Intra-level white space</i> does not participate in standard annotation <i>pairing</i>.
However, if the immediately-adjacent <i>ruby bases</i> or <i>ruby annotations</i>
are paired
<ul>
<li>with two <i>ruby bases</i> or <i title="ruby annotations">annotations</i>
that surround corresponding <i>intra-level white space</i> in another level,
then the so-corresponding <i>intra-level white space</i> boxes are also paired.
<li>with a single spanning <i>ruby annotation</i>,
then the <i>intra-level white space</i> is also paired to that <i>ruby annotation</i>
<li>with two <i>ruby bases</i> or <i title="ruby annotations">annotations</i>
with no intervening <i>intra-level white space</i>,
then the <i>intra-level white space</i> box pairs with
an anonymous empty <i>intra-level white space</i> box assumed to exist between them.
</ul>
<p class=issue id=issue-0230a91a><a class=self-link href=#issue-0230a91a></a>Insert diagram</p>
<h4 class="heading settled" data-level=2.3.3 id=nested-pairing><span class=secno>2.3.3. </span><span class=content>
Complex Spanning with Nested Ruby</span><a class=self-link href=#nested-pairing></a></h4>
<p><dfn data-dfn-type=dfn data-noexport="" id=nested-ruby title="nested ruby"><a class=self-link href=#nested-ruby></a></dfn>When <i>ruby containers</i> are nested,
pairing begins with the deepest <i>ruby container</i>,
then expands out.
From the pairing perspective of the outer <i>ruby container</i>,
each <i>ruby container</i> nested within another <i>ruby container</i>
counts as representing a single <i>ruby base</i>/<i>annotation</i> per level.
The outer <i>ruby container</i>’s <i>ruby annotations</i> paired to the <i>nested ruby</i>
are therefore paired with (and <i>span</i>) all of the nested <i>ruby container</i>’s <i>ruby bases</i>.
Each <i>ruby annotation container</i> in the nested <i>ruby container</i>
occupies the same <i>annotation level</i> in the outer <i>ruby container</i>
as it does in the inner one
and participates in its layout as if it were directly contained in the outer <i>ruby container</i>.
<p>This process is recursive.
Thus, using nested <i>ruby containers</i> allows the representation
of complex spanning relationships.
<p class=issue id=issue-9b177ca3><a class=self-link href=#issue-9b177ca3></a>It’s not clear whether this falls out of layout handling of ruby containers inside ruby bases
or needs to be handled specially.
Waiting until layout is better-defined to find out...
<h3 class="heading settled" data-level=2.4 id=autohide><span class=secno>2.4. </span><span class=content>
Autohiding Base-identical Annotations</span><a class=self-link href=#autohide></a></h3>
<p>If a <i>ruby annotation</i> has the exact same text content as its base,
it is <dfn data-dfn-type=dfn data-noexport="" id=hidden-ruby-annotation title="hidden ruby annotation | hidden annotation">hidden<a class=self-link href=#hidden-ruby-annotation></a></dfn>.
Hiding a <i>ruby annotation</i> does not affect annotation pairing
or the block-axis positioning of boxes in other <i>levels</i>.
However the <i>hidden annotation</i> is not visible,
and it has no impact on layout
other than to separate adjacent sequences of <i>ruby annotation boxes</i> within its level,
as if they belonged to separate segments
and the <i>hidden annotation</i>’s base were not a <i>ruby base</i> 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 hiragana.
For example, the word <span lang=ja>振り仮名</span> 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 pronunciation above its kanji base character." src=images/furigana-separate.png>
<p class=caption>Hiragana ruby for 振り仮名. Notice there is no hiragana annotation above り, since it is already in hiragana.
</div>
</div>
<p>The content comparison for this auto-hiding behavior
takes place prior to white space collapsing (<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-white-space>white-space</a>) and text transformation (<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-text-transform>text-transform</a>)
and ignores elements (considers only the <code>textContent</code> of the boxes).
<p class=note role=note>
Future levels of CSS Ruby may add controls for auto-hiding,
but in this level it is always forced.
<h3 class="heading settled" data-level=2.5 id=white-space><span class=secno>2.5. </span><span class=content>
White Space Collapsing</span><a class=self-link href=#white-space></a></h3>
<p>White space within a ruby structure is <a href=#anon-gen-discard-space>discarded</a>
<ul>
<li>at the beginning and end of a <i>ruby container</i>, <i>ruby annotation container</i>, or <i>ruby base container</i>,
<li>between a <i>ruby base container</i> and its following <i>ruby annotation container</i>,
<li>between <i>ruby annotation containers</i>.
</ul>
<div class=example>
For example, the following markup will display without any spaces:
<pre><ruby>
<rb>東</rb><rb>京</rb>
<rt>とう</rt><rt>きょう</rt>
<rt>Tō</rt><rt>kyō</rt>
</ruby></pre>
</div>
<p>Between <i>ruby segments</i>, between <i>ruby bases</i>, and between <i>ruby annotations</i>, however,
white space is not discarded,
and is maintained for rendering
as <i title="inter-base white space">inter-base</i>,
<i title="inter-annotation white space">inter-annotation</i>,
or <i>inter-segment white space</i>.
(See <a href=#box-fixup>Anonymous Ruby Box Generation</a>, above.)
<div class=example>
<p>The rules preserving white space 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>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 data-biblio-type=normative data-link-type=biblio href=#biblio-css3text title=CSS3TEXT>[CSS3TEXT]</a>
For <i>collapsible white space</i> between <i>ruby segments</i> (<i>inter-segment white space</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 source document order.
<div class=note role=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 Han and Kana characters.
This means that Chinese and Japanese ruby can safely use white space for indentation of ruby markup.
For example, the following markup will display without any spaces:
<pre><ruby>
屋<rt>おく</rt>内<rt>ない</rt>
禁<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>
屋<rt>おく</rt> 内<rt>ない</rt>
禁<rt>きん</rt> 煙<rt>えん</rt>
</ruby></pre>
</div>
<h2 class="heading settled" data-level=3 id=ruby-layout><span class=secno>3. </span><span class=content>
Ruby Layout</span><a class=self-link href=#ruby-layout></a></h2>
<p>When a ruby structure is laid out,
its <i>base level</i> is laid out on the line,
aligned according to its <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-vertical-align>vertical-align</a> property
exactly as if its <i>ruby bases</i> were a regular sequence of inline boxes.
Each <i>ruby base container</i> is sized and positioned
to contain exactly the full height of its <i>ruby bases</i>.
<p><i>Ruby annotations</i> associated with the <i>base level</i>
are then positioned with respect to their <i>ruby base boxes</i>
according to the applicable <a class=property data-link-type=propdesc href=#propdef-ruby-position>ruby-position</a> values.
<i>Ruby annotations</i> within a level (within a single <i>ruby container</i>)
are aligned to each other as if they were inline boxes
participating in the same inline formatting context.
Each <i>ruby annotation container</i> is sized and positioned
to contain exactly the full height of its <i>ruby annotations</i>.
<p>A ruby container (or fragment thereof)
measures as wide as the content of its widest level.
Similarly, <i>ruby base boxes</i> and <i>ruby annotation boxes</i>
within a ruby “column” have the measure of the widest content in that “column”.
In the case of <i>spanning annotations</i>
(whether actually spanning or pretending to span per <a class=property data-link-type=propdesc href=#propdef-ruby-merge>ruby-merge</a>),
the measures of the <i>ruby annotation box</i> and
the sum of its associated <i>ruby base boxes</i> 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 class=property data-link-type=propdesc href=#propdef-ruby-align>ruby-align</a> property.
<h3 class="heading settled" data-level=3.1 id=inter-character-layout><span class=secno>3.1. </span><span class=content>
Inter-character Ruby Layout</span><a class=self-link href=#inter-character-layout></a></h3>
<p>Inter-character annotations have special layout.
When <a class=property data-link-type=propdesc href=#propdef-ruby-position>ruby-position</a> indicates <a class=css data-link-type=maybe href=#valdef-ruby-position-inter-character>inter-character</a> annotations,
the affected <i>ruby annotation boxes</i>
are spliced into and measured as part of the layout of the <i>base level</i>.
The <i>ruby base container</i> must be sized to include both the <i>ruby base boxes</i>
as well as the <a class=css data-link-type=maybe href=#valdef-ruby-position-inter-character>inter-character</a> <i>ruby annotation boxes</i>.
The affected <i>ruby annotation container</i> is similarly sized
so that its content box coincides with that of the <i>ruby base container</i>.
<p>For the purpose of laying out other levels of annotations,
an <a class=css data-link-type=maybe href=#valdef-ruby-position-inter-character>inter-character</a> annotation effectively becomes part of its base.
<span class=issue id=issue-029133da><a class=self-link href=#issue-029133da></a>Or should it become a quasi-base between two bases?</span>
A spanning <a class=css data-link-type=maybe href=#valdef-ruby-position-inter-character>inter-character</a> annotation is placed after
all the bases that it spans.
<h3 class="heading settled" data-level=3.2 id=box-style><span class=secno>3.2. </span><span class=content>
Styling Ruby Boxes</span><a class=self-link href=#box-style></a></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 <i>ruby base container boxes</i>, <i>ruby annotation container boxes</i>,
or <a href=#nested-pairing>ruby-internal ruby container boxes</a>.
The UA may implement these boxes simply as abstractions for inheritance
and control over the layout of their contents.
<h3 class="heading settled" data-level=3.3 id=line-breaks><span class=secno>3.3. </span><span class=content>
Breaking Across Lines</span><a class=self-link href=#line-breaks></a></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 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 <i>ruby base</i>
(and, in parallel, its associated <i>ruby annotation boxes</i>).
<p>Whenever ruby breaks across lines, <i>ruby annotations</i> must stay
with their respective <i>ruby bases</i>.
The line <em>must not</em> break between a <i>ruby base</i> and its <i>annotations</i>,
even in the case of <a class=css data-link-type=maybe href=#valdef-ruby-position-inter-character>inter-character</a> <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><a class=css data-link-type=maybe href=#valdef-ruby-position-inter-character>inter-character</a> ruby line breaking opportunity
</div>
<h4 class="heading settled" data-level=3.3.1 id=break-between><span class=secno>3.3.1. </span><span class=content>
Breaking Between Bases</span><a class=self-link href=#break-between></a></h4>
<p>In typical cases, <i>ruby base boxes</i> and <i>ruby annotation boxes</i>
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 <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>.
<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 <i>ruby bases</i>
is controlled by normal line-breaking rules for the base text,
exactly as if the <i>ruby bases</i> were adjacent inline boxes.
(The annotations are ignored when determining soft wrap opportunities for the <i>base level</i>.)
<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 <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-word-break>word-break</a> is <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-text-3/#valdef-word-break-keep-all>keep-all</a>, 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 <i>ruby bases</i>.
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 data-biblio-type=informative data-link-type=biblio href=#biblio-css3text title=CSS3TEXT>[CSS3TEXT]</a>
</div>
<h4 class="heading settled" data-level=3.3.2 id=break-within><span class=secno>3.3.2. </span><span class=content>
Breaking Within Bases</span><a class=self-link href=#break-within></a></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 id=issue-14d7c6b1><a class=self-link href=#issue-14d7c6b1></a>
Insert scanned example so people don’t think this is just the ramblings of an insane spec-writer.
<p>Line-breaking within a <i>ruby base</i> is only allowed if the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#propdef-white-space>white-space</a> property
of the <i>ruby base</i> 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 correspondence between fragments of content
within <i>ruby bases</i> 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.
<p>There are no line breaking opportunities within <a class=css data-link-type=maybe href=#valdef-ruby-position-inter-character>inter-character</a> <i>annotations</i>.
<p>Ruby alignment takes place within each fragment, after line-breaking.
<h3 class="heading settled" data-level=3.4 id=bidi><span class=secno>3.4. </span><span class=content>
Bidi Reordering</span><a class=self-link href=#bidi></a></h3>
<p>The Unicode bidirectional algorithm reorders logically-stored text for visual presentation
when characters from scripts of opposing directionalities are mixed
within a single paragraph.
<p>To preserve the correspondance of <i>ruby annotations</i>
to their respective <i>ruby bases</i>,
a few restrictions must be imposed:
<ul>
<li>The contents of a <i>ruby base</i> or <i>ruby annotation</i> must remain contiguous.
<li><i>Ruby annotations</i> must be reordered together with their <i>ruby bases</i>.
<li>All <i>ruby bases</i> spanned by a single <i>ruby annotation</i> must remain contiguous.
</ul>
<p>To this end,
<ul>
<li>
Bidi isolation is forced on all <i>internal ruby boxes</i> and the <i>ruby container</i>:
the <a class=css data-link-type=maybe href=http://dev.w3.org/fxtf/compositing-1/#valdef-blend-mode-normal>normal</a> and <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-writing-modes-3/#valdef-unicode-bidi-embed>embed</a> values of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-unicode-bidi>unicode-bidi</a> compute to <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-writing-modes-3/#valdef-unicode-bidi-isolate>isolate</a>,
and <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-writing-modes-3/#valdef-unicode-bidi-bidi-override>bidi-override</a> computes to <a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-writing-modes-3/#valdef-unicode-bidi-isolate-override>isolate-override</a>.
<p class=note role=note>
Note this means that implicit bidi reordering does not work across ruby bases,
so authors will need to ensure that the <i>ruby container</i>’s declared directionality
does indeed match its contents.
<li>
During layout, <i>ruby segments</i> are ordered within the <i>ruby container</i>
by the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-direction>direction</a> property of their <i>ruby container</i>.
<li>
Within a segment, <i>ruby bases</i> and <i>ruby annotations</i>
are ordered within their respective containers
by the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-direction>direction</a> property of the segment’s <i>ruby base container</i>.
<span class=note role=note>
Note this means the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-writing-modes-3/#propdef-direction>direction</a> property on <i>ruby annotation containers</i>
is ignored for the purpose of layout.
However, it can still inherit into the container’s children
and thereby affect the <i>inline base direction</i>
of any <i>ruby annotations</i> it contains.
</span>
</ul>
<p>As with other inline-level content,
the bidi reordering of <i>internal ruby boxes</i> happens after line-breaking
so that content is divided across lines according to its logical order.
<p>See <a data-biblio-type=informative data-link-type=biblio href=#biblio-css3-writing-modes title=CSS3-WRITING-MODES>[CSS3-WRITING-MODES]</a> for a more in-depth discussion of bidirectional text in CSS.
<h3 class="heading settled" data-level=3.5 id=line-height><span class=secno>3.5. </span><span class=content>
Line Spacing</span><a class=self-link href=#line-height></a></h3>
<p>The <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height>line-height</a> property controls spacing between lines in CSS.
When inline content on line is shorter than the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height>line-height</a>,
half-leading is added on either side of the content,
as specified in <a href=http://www.w3.org/TR/CSS21/visudet.html#line-height>CSS2.1§10.8</a>. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=CSS21>[CSS21]</a>
<p>In order to ensure consistent spacing of lines,
documents with ruby typically ensure that the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height>line-height</a> is large enough
to accommodate ruby between lines of text.
Therefore, ordinarily, <i>ruby annotation containers</i> and <i>ruby annotation boxes</i>
do not contribute to the measured height of a line’s inline contents;
any alignment (see <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-vertical-align>vertical-align</a>) and line-height calculations
are performed using only the <i>ruby base container</i>,
exactly as if it were a normal inline.
<p>However, if the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height>line-height</a> specified on the <i>ruby container</i>
is less than the distance between
the top of the top <i>ruby annotation container</i>
and the bottom of the bottom <i>ruby annotation container</i>,
then additional leading is added
on the appropriate side of the <i>ruby base container</i>
such that if a block consisted of three lines
each containing ruby identical to this,
none of the <i>ruby containers</i> would overlap.
<p class=note role=note>Note that this does not ensure that the <i>ruby annotations</i> remain within the line box.
It merely ensures that <em>if all lines had equal spacing</em>
and equivalent amounts and positioning of <i>ruby annotations</i>,
there would be enough room to avoid overlap.
<p>Authors should ensure appropriate <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-line-height>line-height</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/box.html#propdef-padding>padding</a> to accommodate ruby,
and be particularly careful at the beginning or end of a block
and when a line contains inline-level content
(such as images, inline blocks, or elements shifted with <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-vertical-align>vertical-align</a>)
taller than the paragraph’s default font size.
<div class=figure>
<p><img alt="The content of each line sits in the middle of its line height;