-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
5432 lines (5406 loc) · 398 KB
/
Overview.html
File metadata and controls
5432 lines (5406 loc) · 398 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><html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>CSS basic box model</title>
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<meta content="rewriting" name="csswg-work-status">
<meta content="ED" name="w3c-status">
<meta content=" <![CDATA[<p><abbr title="Cascading Style Sheets">CSS</abbr> describes the rendering of documents on various media. When textual documents (e.g., HTML) are laid out on visual media (e.g., screen or print), CSS models their layout as a collection of rectangular boxes containing words, lines, paragraphs, tables, etc., each with properties such as size, color and font. <p>This module describes the basic types of boxes: block, list item, inline, etc.; and some of their properties, including margins, padding and width/height. It defines a layout called a “flow,” in which a series of boxes is laid out one after the other, and it defines “floating” boxes. Other kinds of layout, such as tables, absolute positioning, ruby annotations, grid layouts, columns and page boxes, are described by other modules. Also, the layout of text inside a line (including the handling of left-to-right and right-to-left scripts) is defined elsewhere. <p>In CSS level 3, boxes may contain either horizontal or vertical text. Different orientations can be mixed. ]]> " name="abstract">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
body {
background-image: url("https://www.w3.org/StyleSheets/TR/logo-ED");
};
</style>
<meta content="Bikeshed 1.0.0" name="generator">
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<link href="../default.css" rel="stylesheet" type="text/css">
<style type="text/css">
ol.stack p {margin-top: 0}
img.small {max-width: 100%}
.minidiagram {height: 6em; vertical-align: middle}
dt {display: inline}
dt + dt::before {content: ", "}
/* Undo the max-width in the 2012 style for editor’s drafts: */
/* maybe replace this with using default.css’s class=data? */
.equiv-table {margin: 0.5em 0; border-collapse: collapse;
border-bottom: hidden; empty-cells: show}
.equiv-table th, .equiv-table td {padding: 0.3em 1em;
border-bottom: thin solid #666}
.equiv-table th {text-align: left}
/* .equiv-table th:first-child {text-align: right} */
.equiv-table caption {margin: 0.5em 0 0 0}
.equiv-table td > p:first-child, .equiv-table th > p:first-child {
margin-top: 0}
.equiv-table tr {vertical-align: baseline}
.equiv-table img {max-width: 100%}
/* The TR postprocessor already inserted quotes: */
.css::before, .property::before, .descriptor::before {content: none}
.css::after, .property::after, .descriptor::after {content: none}
@media screen {
#annoying-warning:not(:checked) + * + * {position: fixed; z-index: 2;
bottom: 2em; left: 0; right: 0; text-align: center;
padding: 0.5em 0.5em 1em 0.5em; box-shadow: 0 2px 8px black;
border-top: thin solid; border-bottom: thin solid;
background: hsla(40,100%,50%,0.9); color: black}
#annoying-warning:not(:checked) + * + * p {margin: 0}
#annoying-warning, #annoying-warning + * {position: fixed; z-index: 3}
#annoying-warning {font-size: 1em; bottom: 2.3em; right: 0.5em; margin: 0}
#annoying-warning + * {font-size: 80%; bottom: 2.5em; right: 2.3em}
#annoying-warning:checked, #annoying-warning:checked + * {display: none}
html {margin-bottom: 15em}
}
</style>
<link href="https://www.w3.org/StyleSheets/TR/W3C-ED.css" rel="stylesheet" title="Default" type="text/css">
<link href="#contents" rel="contents">
<link href="#index" rel="index">
<style>/* style-md-lists */
/* This is a weird hack for me not yet following the commonmark spec
regarding paragraph and lists. */
[data-md] > :first-child {
margin-top: 0;
}
[data-md] > :last-child {
margin-bottom: 0;
}</style>
<style>/* style-counters */
body {
counter-reset: example figure issue;
}
.issue {
counter-increment: issue;
}
.issue:not(.no-marker)::before {
content: "Issue " counter(issue);
}
.example {
counter-increment: example;
}
.example:not(.no-marker)::before {
content: "Example " counter(example);
}
.invalid.example:not(.no-marker)::before,
.illegal.example:not(.no-marker)::before {
content: "Invalid Example" counter(example);
}
figcaption {
counter-increment: figure;
}
figcaption:not(.no-marker)::before {
content: "Figure " counter(figure) " ";
}</style>
<style>/* style-dfn-panel */
.dfn-panel {
position: absolute;
z-index: 35;
height: auto;
width: -webkit-fit-content;
width: fit-content;
max-width: 300px;
max-height: 500px;
overflow: auto;
padding: 0.5em 0.75em;
font: small Helvetica Neue, sans-serif, Droid Sans Fallback;
background: #DDDDDD;
color: black;
border: outset 0.2em;
}
.dfn-panel:not(.on) { display: none; }
.dfn-panel * { margin: 0; padding: 0; text-indent: 0; }
.dfn-panel > b { display: block; }
.dfn-panel a { color: black; }
.dfn-panel a:not(:hover) { text-decoration: none !important; border-bottom: none !important; }
.dfn-panel > b + b { margin-top: 0.25em; }
.dfn-panel ul { padding: 0; }
.dfn-panel li { list-style: inside; }
.dfn-panel.activated {
display: inline-block;
position: fixed;
left: .5em;
bottom: 2em;
margin: 0 auto;
max-width: calc(100vw - 1.5em - .4em - .5em);
max-height: 30vh;
}
.dfn-paneled { cursor: pointer; }
</style>
<style>/* style-selflinks */
.heading, .issue, .note, .example, li, dt {
position: relative;
}
a.self-link {
position: absolute;
top: 0;
left: calc(-1 * (3.5rem - 26px));
width: calc(3.5rem - 26px);
height: 2em;
text-align: center;
border: none;
transition: opacity .2s;
opacity: .5;
}
a.self-link:hover {
opacity: 1;
}
.heading > a.self-link {
font-size: 83%;
}
li > a.self-link {
left: calc(-1 * (3.5rem - 26px) - 2em);
}
dfn > a.self-link {
top: auto;
left: auto;
opacity: 0;
width: 1.5em;
height: 1.5em;
background: gray;
color: white;
font-style: normal;
transition: opacity .2s, background-color .2s, color .2s;
}
dfn:hover > a.self-link {
opacity: 1;
}
dfn > a.self-link:hover {
color: black;
}
a.self-link::before { content: "¶"; }
.heading > a.self-link::before { content: "§"; }
dfn > a.self-link::before { content: "#"; }</style>
<style>/* style-autolinks */
.css.css, .property.property, .descriptor.descriptor {
color: #005a9c;
font-size: inherit;
font-family: inherit;
}
.css::before, .property::before, .descriptor::before {
content: "‘";
}
.css::after, .property::after, .descriptor::after {
content: "’";
}
.property, .descriptor {
/* Don't wrap property and descriptor names */
white-space: nowrap;
}
.type { /* CSS value <type> */
font-style: italic;
}
pre .property::before, pre .property::after {
content: "";
}
[data-link-type="property"]::before,
[data-link-type="propdesc"]::before,
[data-link-type="descriptor"]::before,
[data-link-type="value"]::before,
[data-link-type="function"]::before,
[data-link-type="at-rule"]::before,
[data-link-type="selector"]::before,
[data-link-type="maybe"]::before {
content: "‘";
}
[data-link-type="property"]::after,
[data-link-type="propdesc"]::after,
[data-link-type="descriptor"]::after,
[data-link-type="value"]::after,
[data-link-type="function"]::after,
[data-link-type="at-rule"]::after,
[data-link-type="selector"]::after,
[data-link-type="maybe"]::after {
content: "’";
}
[data-link-type].production::before,
[data-link-type].production::after,
.prod [data-link-type]::before,
.prod [data-link-type]::after {
content: "";
}
[data-link-type=element],
[data-link-type=element-attr] {
font-family: Menlo, Consolas, "DejaVu Sans Mono", monospace;
font-size: .9em;
}
[data-link-type=element]::before { content: "<" }
[data-link-type=element]::after { content: ">" }
[data-link-type=biblio] {
white-space: pre;
}</style>
<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/StyleSheets/TR/2016/logos/W3C" width="72"> </a> </p>
<h1>CSS basic box model</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2016-09-07">7 September 2016</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-box/">http://dev.w3.org/csswg/css-box/</a>
<dt>Latest published version:
<dd><a href="https://www.w3.org/TR/css-box-3/">https://www.w3.org/TR/css-box-3/</a>
<dt>Previous Versions:
<dd><a href="http://www.w3.org/TR/2007/WD-css3-box-20070809/" rel="previous">http://www.w3.org/TR/2007/WD-css3-box-20070809/</a>
<dt>Issue Tracking:
<dd><a href="#issues-index">Inline In Spec</a>
<dd><span><a href="https://github.com/w3c/csswg-drafts/labels/css-box-3">GitHub Issues</a></span>
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:mailto:bert@w3.org">Bert Bos</a> (<span class="p-org org">W3C</span>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:mailto:prowse@moonhenge.net">Anton Prowse</a> (<span class="p-org org">Invited Expert</span>)
</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> © 2016 <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>). 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><abbr title="Cascading Style Sheets">CSS</abbr> describes the
rendering of documents on various media. When textual documents (e.g.,
HTML) are laid out on visual media (e.g., screen or print), CSS models
their layout as a collection of rectangular boxes containing words, lines,
paragraphs, tables, etc., each with properties such as size, color and
font.</p>
<p>This module describes the basic types of boxes: block, list item,
inline, etc.; and some of their properties, including margins, padding
and width/height. It defines a layout called a “flow,” in which a
series of boxes is laid out one after the other, and it defines
“floating” boxes. Other kinds of layout, such as tables, absolute
positioning, ruby annotations, grid layouts, columns and page boxes,
are described by other modules. Also, the layout of text inside a line
(including the handling of left-to-right and right-to-left scripts) is
defined elsewhere. </p>
<p>In CSS level 3, boxes may contain either horizontal or vertical text.
Different orientations can be mixed.
]]> <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.</p>
</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>
<p> <a href="https://github.com/w3c/csswg-drafts/issues">GitHub Issues</a> are preferred for discussion of this specification.
When filing an issue, please put the text “css-box” in the title,
preferably like this:
“[css-box] <em>…summary of comment…</em>”.
All issues and comments are <a href="https://lists.w3.org/Archives/Public/public-css-archive/">archived</a>,
and there is also a <a href="http://lists.w3.org/Archives/Public/www-style/">historical archive</a>. </p>
<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>
<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>
<p> This document is governed by the <a href="http://www.w3.org/2015/Process-20150901/" id="w3c_process_revision">1 September 2015 W3C Process Document</a>. </p>
<p></p>
<p></p>
<div>
<input id="annoying-warning" title="hide
warning" type="checkbox">
<label for="annoying-warning">(hide)</label>
<div>
<p>This
draft is undergoing changes and many parts are not consistent with
other modules of CSS. </p>
<p>Please, refer to CSS level 2 <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a> instead for the definition of the basic box model. </p>
</div>
</div>
<p></p>
<p>This module should eventually replace corresponding parts of the
revised CSS level 2 specification <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>. But this is an early
draft and any differences to level 2 are most likely unintentional,
unless they concern new features, such as vertical text or float
displacement. <em>Please help us improve the next draft by pointing
out such differences.</em> ]]> </p>
</div>
<div data-fill-with="at-risk"></div>
<nav data-fill-with="table-of-contents" id="toc">
<h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
<ol class="toc" role="directory">
<li><a href="#dependencies"><span class="secno">1</span> <span class="content">Dependencies on other modules</span></a>
<li><a href="#intro"><span class="secno">2</span> <span class="content">Introduction & definitions</span></a>
<li><a href="#viewport"><span class="secno">3</span> <span class="content">The viewport and the canvas</span></a>
<li><a href="#cb"><span class="secno">4</span> <span class="content">Containing blocks</span></a>
<li><a href="#flows"><span class="secno">5</span> <span class="content">Flows</span></a>
<li>
<a href="#boxes"><span class="secno">6</span> <span class="content">Types of boxes</span></a>
<ol class="toc">
<li><a href="#block-level-cb-flows"><span class="secno">6.1</span> <span class="content">Block-level boxes, containing blocks
and anonymous boxes</span></a>
<li><a href="#compact-boxes"><span class="secno">6.2</span> <span class="content">Compact boxes</span></a>
<li><a href="#mixing"><span class="secno">6.3</span> <span class="content">Mixing the box model with other formatting models</span></a>
</ol>
<li><a href="#block-level0"><span class="secno">7</span> <span class="content">Block-level formatting</span></a>
<li><a href="#padding-props"><span class="secno">8</span> <span class="content">The padding properties</span></a>
<li><a href="#margin-props"><span class="secno">9</span> <span class="content">The margin properties</span></a>
<li><a href="#width-and-height"><span class="secno">10</span> <span class="content">The width and height properties</span></a>
<li><a href="#min-max"><span class="secno">11</span> <span class="content">The min-width, max-width, min-height and
max-height properties</span></a>
<li><a href="#aspect"><span class="secno">12</span> <span class="content"><span class="index">Aspect ratios</span> of replaced elements</span></a>
<li><a href="#collapsing-margins"><span class="secno">13</span> <span class="content">Collapsing margins</span></a>
<li><a href="#inline-level0"><span class="secno">14</span> <span class="content">Inline-level formatting</span></a>
<li>
<a href="#Calculating"><span class="secno">15</span> <span class="content">Calculating widths, heights and margins</span></a>
<ol class="toc">
<li><a href="#inline-non-replaced"><span class="secno">15.1</span> <span class="content">Inline, non-replaced
elements</span></a>
<li><a href="#inline-replaced"><span class="secno">15.2</span> <span class="content">Inline or floating, replaced
elements</span></a>
<li><a href="#blockwidth"><span class="secno">15.3</span> <span class="content">Block-level, non-replaced elements
in normal flow
when <span class="property">overflow</span> computes to <span class="css">visible</span></span></a>
<li><a href="#other-block-level"><span class="secno">15.4</span> <span class="content">Other block-level, non-replaced elements in normal flow</span></a>
<li><a href="#inline-block-or-floating"><span class="secno">15.5</span> <span class="content"><span class="property">Inline-block</span> or floating, non-replaced
elements</span></a>
<li><a href="#abs-non-replaced-width"><span class="secno">15.6</span> <span class="content">Absolutely positioned, non-replaced
elements</span></a>
<li><a href="#abs-replaced"><span class="secno">15.7</span> <span class="content">Absolutely positioned, replaced
elements</span></a>
<li><a href="#block-level-replaced"><span class="secno">15.8</span> <span class="content">Block-level, replaced elements in normal flow</span></a>
<li><a href="#floating"><span class="secno">15.9</span> <span class="content">Floating, non-replaced elements</span></a>
<li><a href="#root-height"><span class="secno">15.10</span> <span class="content">Auto heights for flow roots</span></a>
</ol>
<li>
<a href="#float-prop"><span class="secno">16</span> <span class="content">The float property</span></a>
<ol class="toc">
<li><a href="#intro-to-floats"><span class="secno">16.1</span> <span class="content">Introduction to floats</span></a>
<li><a href="#float-rules"><span class="secno">16.2</span> <span class="content">Rules for positioning floats</span></a>
</ol>
<li><a href="#clear-prop"><span class="secno">17</span> <span class="content">The clear property</span></a>
<li><a href="#clear-after-prop"><span class="secno">18</span> <span class="content">The clear-after property</span></a>
<li>
<a href="#overflow-intro"><span class="secno">19</span> <span class="content">Overflow</span></a>
<ol class="toc">
<li><a href="#overflow-props"><span class="secno">19.1</span> <span class="content">The overflow, overflow-x and overflow-y properties</span></a>
</ol>
<li><a href="#visibility-prop"><span class="secno">20</span> <span class="content">The visibility property</span></a>
<li>
<a href="#stacking"><span class="secno">21</span> <span class="content">Stacking contexts</span></a>
<ol class="toc">
<li><a href="#definitions"><span class="secno">21.1</span> <span class="content">Definitions</span></a>
<li><a href="#painting"><span class="secno">21.2</span> <span class="content">Painting order</span></a>
<li><a href="#notes"><span class="secno">21.3</span> <span class="content">Notes</span></a>
</ol>
<li>
<a href="#float-displace-1"><span class="secno">22</span> <span class="content">The <span class="property">float-displace</span> and <span class="property">indent-edge-reset</span> properties [alternative 1]</span></a>
<ol class="toc">
<li><a href="#float-displace-prop"><span class="secno">22.1</span> <span class="content">The <span class="property">float-displace</span> property</span></a>
<li><a href="#indent-edge-reset-prop"><span class="secno">22.2</span> <span class="content">The <span class="property">indent-edge-reset</span> property</span></a>
</ol>
<li><a href="#float-displace-2"><span class="secno"></span> <span class="content">The ‘float-displace’ property [alternative 2]</span></a>
<li><a href="#float-displace-3"><span class="secno"></span> <span class="content">The ‘float-displace’ property [alternative 3]</span></a>
<li><a href="#acknowledgments"><span class="secno">23</span> <span class="content">Acknowledgments</span></a>
<li>
<a href="#conformance"><span class="secno"></span> <span class="content"> Conformance</span></a>
<ol class="toc">
<li><a href="#document-conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a>
<li><a href="#conform-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a>
<li>
<a href="#conform-responsible"><span class="secno"></span> <span class="content"> Requirements for Responsible Implementation of CSS</span></a>
<ol class="toc">
<li><a href="#conform-partial"><span class="secno"></span> <span class="content"> Partial Implementations</span></a>
<li><a href="#conform-future-proofing"><span class="secno"></span> <span class="content"> Implementations of Unstable and Proprietary Features</span></a>
<li><a href="#conform-testing"><span class="secno"></span> <span class="content"> Implementations of CR-level Features</span></a>
</ol>
</ol>
<li>
<a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ol class="toc">
<li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ol>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ol 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>
</ol>
<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>
</ol>
</nav>
<main>
<p></p>
<title>CSS basic box model</title>
<h2 class="heading settled" data-level="1" id="dependencies"><span class="secno">1. </span><span class="content">Dependencies on other modules</span><a class="self-link" href="#dependencies"></a></h2>
<p>This CSS module depends on the following other CSS modules: </p>
<p class="issue" id="issue-5b645b7b"><a class="self-link" href="#issue-5b645b7b"></a>To do… </p>
<h2 class="heading settled" data-level="2" id="intro"><span class="secno">2. </span><span class="content">Introduction & definitions</span><a class="self-link" href="#intro"></a></h2>
<div class="issue" id="center-text">
<a class="self-link" href="#center-text"></a>
<p>How to center the text of a block element horizontally (more
precisely: in the inline direction) even if (part of) the block is
next to a float? </p>
</div>
<div class="issue" id="center-block">
<a class="self-link" href="#center-block"></a>
<p>How to center a block horizontally in its CB if the block is wider
than the CB? (I.e., when 'margin: auto' doesn’t work and the document
structure doesn’t allow transforms or flexbox.) </p>
</div>
<div class="issue" id="distribute">
<a class="self-link" href="#distribute"></a>
<p>How to center or distribute blocks vertically when flexbox doesn’t
apply (e.g., because the blocks aren’t siblings)? </p>
</div>
<div class="issue" id="anonymous-box-pseudo">
<a class="self-link" href="#anonymous-box-pseudo"></a>
<p>Investigate if it is possible to make a pseudo-element to select
anonymous boxes ('::paragraph'). See minutes of 10 Aug 2011. </p>
</div>
<p class="note" role="note">Note: The model in this specification differs from the
model described in the CSS level 2 specification <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>, because
it is generalized to apply also to vertical text. A document using
only features from level 2 renders exactly as described there, except
possibly for features that are undefined in that specification and
have become defined since. </p>
<p>CSS assumes that the document to lay out is modeled as a <span class="index" title="tree!!of elements|document tree|element
tree">tree</span> of <dfn data-dfn-type="dfn" data-noexport="" id="elements" title="element">elements.<a class="self-link" href="#elements"></a></dfn> Each element
has an ordered list of zero or more child elements, with an optional
string of text before the list, in-between the children and after the
list. Each child has one parent, except for the unique element that
has no parent, which is called the <dfn data-dfn-type="dfn" data-noexport="" id="root-element">root element.<a class="self-link" href="#root-element"></a></dfn> </p>
<p class="note" role="note">Note that such a tree can be described in XML or SGML,
but also in other notations and that it is the definition of that
notation, not CSS, that determines the equivalence between the
abstract tree and the concrete notation. E.g., SGML often allows white
space to be added between elements for readability, which does not
result in a string of spaces in the abstract tree. </p>
<p>CSS describes how each element and each string of text is laid out
by transforming the document tree into a set of boxes, whose size,
position, and stacking level on the <a data-link-type="dfn" href="#canvas" id="ref-for-canvas-1">canvas</a> depend on their
properties. We say that an element <dfn data-dfn-type="dfn" data-noexport="" id="generates" title="generated
box">generates<a class="self-link" href="#generates"></a></dfn> one or more boxes. </p>
<div class="issue" id="box-tree">
<a class="self-link" href="#box-tree"></a>
<p>Define the box tree </p>
</div>
<div class="figure">
<p><img alt="Each generated box in the rendering
has a link to the element that generated it." src="box-intro.png"> </p>
<p class="caption">Relation between four displayed boxes in the
rendered document (on the right) and the three corresponding elements
in the source document on the (left). </p>
</div>
<div class="example" id="example-a6f82987">
<a class="self-link" href="#example-a6f82987"></a>
<p>For example, a fragment of HTML such as </p>
<pre><ul> <li>The first item in the list.
<li>The second item.
</ul></pre>
<p>may result in <span class="issue" id="issue-8d8c38c4"><a class="self-link" href="#issue-8d8c38c4"></a>[rewrite the following
sentence?]</span> one block-level box for the <code>ul</code> element,
containing two block-level boxes for the two <code>li</code> elements,
each of which has one line box (i.e., one line of text). Both line
boxes contain two inline-level boxes: one that contains the list
bullet and one that contains the text. </p>
<p>Note how the <code>li</code> is transformed into multiple boxes, including
one that contains “generated content,” viz., the list bullet,
which is not present in the source document. </p>
<p>If the document is rendered in a narrow window, it may be that the <code>li</code> elements get transformed into even more boxes, because the
text requires multiple lines. And if the document is rendered on paper
or in multiple columns, it
may be that a page break falls in the middle of the <code>ul</code> element,
so that it is not transformed into a single block-level box, but into two
smaller ones, each on a different page or column. </p>
</div>
<p>Each box belongs to exactly one element. It is either <a data-link-type="dfn" title="generated box">generated</a> directly by the element, or it
is an <a data-link-type="dfn" href="#anonymous-box" id="ref-for-anonymous-box-1">anonymous box,</a> which has been inserted to ensure that
every box and its parent are of mutually compatible types as defined
by the layout rules of CSS. An anonymous box is defined to belong to
whichever element generates the box’s closest element-generated
ancestor box. When we need to be precise, we say that the anonymous
box is <dfn data-dfn-type="dfn" data-noexport="" id="induced" title="induce">induced,<a class="self-link" href="#induced"></a></dfn> rather than generated, by
the element it belongs to. </p>
<p class="note" role="note">For example, an anonymous table wrapper box that is
created around a table cell because the table cell element doesn’t
have a table element as parent, belongs to the parent element of the
table cell, not to the table cell itself. </p>
<p class="note" role="note">An anonymous box is never a <em>principal</em> box. Except for that, an anonymous box cannot be distinguished by its
property values and characteristics from a box generated by some
hypothetical document element. <span class="issue" id="issue-d94120a2"><a class="self-link" href="#issue-d94120a2"></a>Remove this note? Do
we actually use the concept of “principal box” anywhere?</span> </p>
<div class="issue" id="issue-1396385e">
<a class="self-link" href="#issue-1396385e"></a>
<p>Do boxes have properties? Or do they just have margins, borders,
padding, a size and some content (which may be text in a certain font
and a certain color, but without the box itself having a font or a
color property)? </p>
</div>
<div class="figure" id="various">
<p><img alt="Diagram of a typical box, showing the
content, padding, border and margin areas" src="box.png"> </p>
<p class="caption">The various areas and edges of a typical box </p>
</div>
<p>Boxes have padding, a border and margins (see
the <a href="#various">figure</a>). Different properties determine the
thickness of each of these (which may be zero). The margins of
adjacent boxes are also subject
to <em title="collapse">collapsing</em> (i.e., the actual margin
between adjacent boxes may be less than the sum of the boxes'
individual margins). </p>
<p>Each box has a <dfn data-dfn-type="dfn" data-noexport="" id="content-area">content area<a class="self-link" href="#content-area"></a></dfn> (a.k.a. <dfn data-dfn-type="dfn" data-lt="content box" data-noexport="" id="content-box">content
box<a class="self-link" href="#content-box"></a></dfn>). The rectangle that bounds this area is the <dfn data-dfn-type="dfn" data-lt="content edge." data-noexport="" id="content-edge">content
edge.<a class="self-link" href="#content-edge"></a></dfn> Around the content area is the <dfn data-dfn-type="dfn" data-noexport="" id="padding-area">padding area<a class="self-link" href="#padding-area"></a></dfn> and
its outside bounds are called the <dfn data-dfn-type="dfn" data-noexport="" id="padding-edge">padding edge<a class="self-link" href="#padding-edge"></a></dfn>. The padding
area and content area together form the <dfn data-dfn-type="dfn" data-noexport="" id="padding-box">padding box<a class="self-link" href="#padding-box"></a></dfn>.
Outside the padding is the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="border-area">border area</dfn> and the outside
boundary of that area is the <dfn data-dfn-type="dfn" data-noexport="" id="border-edge">border edge<a class="self-link" href="#border-edge"></a></dfn>/ The border area,
padding area and content area together form the <dfn data-dfn-type="dfn" data-noexport="" id="border-box">border box<a class="self-link" href="#border-box"></a></dfn>.
Finally, outside the border is the <dfn data-dfn-type="dfn" data-noexport="" id="margin-area">margin area<a class="self-link" href="#margin-area"></a></dfn> and its
outer edge is the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="margin-edge">margin edge</dfn>. </p>
<p>When the specification says that the padding or border is <dfn data-dfn-type="dfn" data-noexport="" id="absent" title="absent|padding!!absent|border!!absent">“absent”<a class="self-link" href="#absent"></a></dfn> on some side of the box, that means that
its thickness is zero. </p>
<p><em title="line box">Line boxes</em> cannot have any padding,
border or margin, and therefore their margin edge, border edge,
padding edge and content edge all coincide. </p>
<p class="note" role="note">Note that the margin, unlike the border and padding, may have
a negative thickness. That is one way to make adjacent boxes overlap each
other. </p>
<p class="note" role="note">Note that the edges always form rectangles, even if
there is a <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-backgrounds-3/#border-radius">border-radius</a> <a data-link-type="biblio" href="#biblio-css3bg">[CSS3BG]</a> or a shape <a data-link-type="biblio" href="#biblio-css3-exclusions">[CSS3-EXCLUSIONS]</a>. </p>
<p>We say that a box or element is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="horizontal">horizontal</dfn> if its <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">writing-mode</a> property is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-horizontal-tb">horizontal-tb</a>, otherwise it is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="vertical">vertical</dfn> (see <a data-link-type="biblio" href="#biblio-css3-writing-modes">[CSS3-WRITING-MODES]</a>). </p>
<p class="mtb">Calculations of the size and position of boxes are
usually very similar for horizontal and vertical boxes, except that
the horizontal and vertical directions are interchanged. To avoid many
almost identical definitions, this specification therefore often uses
abstract terms instead of top, right, bottom, left, width and height:
four terms (block-start, block-end, inline-start and inline-end) for
the four edges of a box, four terms (A edge, B edge, C edge and D
edge) for the edges of the children of a box and two terms (measure
and extent) for the width and height of a box. </p>
<p class="note" role="note">XSL-FO <a data-link-type="biblio" href="#biblio-xsl11">[XSL11]</a> uses “inline-progression dimension” for
“measure” and “block-progression dimension” for “extent.” </p>
<div class="note" role="note">
<p>The following terms are defined in <a data-link-type="biblio" href="#biblio-css3-writing-modes">[CSS3-WRITING-MODES]</a>. For
convenience, here is a short summary. </p>
<p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="block-start">block-start</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="block-end">block-end</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="inline-start">inline-start</dfn> and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="inline-end">inline-end</dfn> edge of a box refer to the top, right, bottom
and left edges, depending on the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">writing-mode</a> and <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> properties of that box, as follows: </p>
<table class="equiv-table">
<thead>
<tr>
<th><a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">writing-mode</a>
<th><a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a>
<th>“block-start”
<th>“inline-end”
<th>“block-end”
<th>“inline-start”
<th>Diagram
<tbody>
<tr>
<th rowspan="2"><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-horizontal-tb">horizontal-tb</a>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>
<td>top
<td>right
<td>bottom
<td>left
<td><img alt="" class="minidiagram" src="box-tb-ltr.svg">
<tr>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>
<td>top
<td>left
<td>bottom
<td>right
<td><img alt="" class="minidiagram" src="box-tb-rtl.svg">
<tr>
<th rowspan="2"><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-vertical-rl">vertical-rl</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-sideways-rl">sideways-rl</a>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>
<td>right
<td>bottom
<td>left
<td>top
<td><img alt="" class="minidiagram" src="box-rl-ltr.svg">
<tr>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>
<td>right
<td>top
<td>left
<td>bottom
<td><img alt="" class="minidiagram" src="box-rl-rtl.svg">
<tr>
<th rowspan="2"><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-vertical-lr">vertical-lr</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-sideways-lr">sideways-lr</a>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>
<td>left
<td>bottom
<td>right
<td>top
<td><img alt="" class="minidiagram" src="box-lr-ltr.svg">
<tr>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>
<td>left
<td>top
<td>right
<td>bottom
<td><img alt="" class="minidiagram" src="box-lr-rtl.svg">
</table>
<p>For example, the “block-start padding” by default refers
to the <a class="property" data-link-type="propdesc" href="#propdef-padding-top" id="ref-for-propdef-padding-top-1">padding-top</a> and the “inline-end border” is by default the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-backgrounds-3/#border-right">border-right</a>. </p>
<p>Similarly, the specification sometimes refers to the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="measure">measure</dfn> and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="extent">extent</dfn> of a box, instead of width
and height, as follows: </p>
<table class="equiv-table">
<tbody>
<tr>
<th><a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">Writing-mode</a>
<th>“measure”
<th>“extent”
<tr>
<td><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-horizontal-tb">horizontal-tb</a>
<td>width
<td>height
<tr>
<td><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-vertical-rl">vertical-rl</a>
<td>height
<td>width
<tr>
<td><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-sideways-rl">sideways-rl</a>
<td>height
<td>width
<tr>
<td><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-vertical-lr">vertical-lr</a>
<td>height
<td>width
<tr>
<td><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-sideways-lr">sideways-lr</a>
<td>height
<td>width
</table>
<p>These correspond to the dimensions in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-base-direction">inline base
direction</a> and the <a data-link-type="dfn">block flow direction,</a> respectively. </p>
<p>An alternative term for the measure is <dfn data-dfn-type="dfn" data-noexport="" id="logical-width" title="logical
width|width!!logical">logical width<a class="self-link" href="#logical-width"></a></dfn> and an alternative term for
extent is <dfn data-dfn-type="dfn" data-noexport="" id="logical-height" title="logical height|height!!logical">logical height.<a class="self-link" href="#logical-height"></a></dfn> These terms occasionally occur in other CSS
modules. </p>
<p>The extent of a box is thus the distance between the
block-start and block-end edges, while the measure of the box is the
distance between the inline-start and inline-end edges. </p>
</div>
<p>When boxes are laid out to form a <a class="index" data-link-type="dfn" href="#flow" id="ref-for-flow-1">flow</a> (see
below), their edges play different roles in the alignment of the boxes
within that flow. The orientation of the flow determines which edge of
a box is aligned to which edge of another box. These roles are
independent of the orientation of the box itself. We distinguish four
roles for the edges of a box, called <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="A|A edge" data-noexport="" id="a">A
edge</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="B|B edge" data-noexport="" id="b">B edge</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="C|C edge" data-noexport="" id="c">C
edge</dfn> and <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="D|D edge" data-noexport="" id="d">D edge</dfn>. They depend on the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">writing-mode</a> and <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> properties of the box’s <em class="index">containing block</em> (defined below), and map to the four sides as
follows: </p>
<table class="equiv-table">
<thead>
<tr>
<th><a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">writing-mode</a> of<br><a data-link-type="dfn" href="#containing-block" id="ref-for-containing-block-1">containing block</a>
<th><a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> of<br><a data-link-type="dfn" href="#containing-block" id="ref-for-containing-block-2">containing block</a>
<th>“A edge”
<th>“B edge”
<th>“C edge”
<th>“D edge”
<tbody>
<tr>
<th rowspan="2"><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-horizontal-tb">horizontal-tb</a>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>
<td>top
<td>right
<td>bottom
<td>left
<tr>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>
<td>top
<td>left
<td>bottom
<td>right
<tr>
<th rowspan="2"><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-vertical-rl">vertical-rl</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-sideways-rl">sideways-rl</a>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>
<td>right
<td>bottom
<td>left
<td>top
<tr>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>
<td>right
<td>top
<td>left
<td>bottom
<tr>
<th rowspan="2"><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-vertical-lr">vertical-lr</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-writing-mode-sideways-lr">sideways-lr</a>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>
<td>left
<td>bottom
<td>right
<td>top
<tr>
<th><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>
<td>left
<td>top
<td>right
<td>bottom
</table>
<div class="figure">
<p><img alt="Image: A box with edges labeled
clockwise from top as A, B, C and D." src="abcd-edges"> </p>
<p class="caption">The edges of a box whose containing block is
horizontal. </p>
</div>
<p class="note" role="note">For example, block-level boxes in a flow are laid out
such that the A edge of the first box is against the block-start edge
of the containing block and then the A edge of each subsequent box is
put against the C edge of its predecessor. For typical English text
(i.e., <a data-link-type="dfn" href="#horizontal" id="ref-for-horizontal-1">horizontal</a> text), this means the top edge (= A edge)
of the first paragraph is at the top edge (= block-start) of the
document, the top (A edge) of the second paragraph is against the
bottom (C edge) of the first paragraph, and so on, until the bottom (C
edge) of the last paragraph becomes the bottom (block-end) of the
document. </p>
<p>An element is called <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="orthogonal">orthogonal</dfn> if it is either a <a data-link-type="dfn" href="#vertical" id="ref-for-vertical-1">vertical</a> element with a <a data-link-type="dfn" href="#horizontal" id="ref-for-horizontal-2">horizontal</a> <a data-link-type="dfn" href="#containing-block" id="ref-for-containing-block-3">containing
block</a> or a <a data-link-type="dfn" href="#horizontal" id="ref-for-horizontal-3">horizontal</a> element with a <a data-link-type="dfn" href="#vertical" id="ref-for-vertical-2">vertical</a> <a data-link-type="dfn">containing block.</a> An <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="orthogonal-flow">orthogonal flow</dfn> is a <a data-link-type="dfn" href="#flow" id="ref-for-flow-2">flow</a> whose <a data-link-type="dfn" href="#flow-root" id="ref-for-flow-root-1">flow root</a> is an orthogonal element. </p>
<h2 class="heading settled" data-level="3" id="viewport"><span class="secno">3. </span><span class="content">The viewport and the canvas</span><a class="self-link" href="#viewport"></a></h2>
<p>User agents for continuous media generally offer users a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="viewport0">viewport</dfn> (a window or other viewing area on the screen)
through which users consult a document. User agents may change the
document’s layout when the viewport is resized (see the <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#initial-containing-block">initial
containing block</a>). </p>
<p>When the viewport is smaller than the area of the <a data-link-type="dfn" href="#canvas" id="ref-for-canvas-2">canvas</a> (see below) on which the document is rendered, the user agent usually
offers a scrolling mechanism. There is at most one viewport per canvas,
but user agents may render to more than one canvas (i.e., provide
different views of the same document). </p>
<p>For all media, the term <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="canvas">canvas</dfn> describes the space where
the formatting structure is rendered. The canvas is infinite for each
dimension of the space. </p>
<h2 class="heading settled" data-level="4" id="cb"><span class="secno">4. </span><span class="content">Containing blocks</span><a class="self-link" href="#cb"></a></h2>
<p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="containing-block">containing block</dfn> of a box is a rectangle that
is associated with the box and that is used in various definitions in this
specification. Apart from a size and a position, the rectangle also has <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> and <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">writing-mode</a> properties. The containing block of a box
is defined as follows: </p>
<ul>
<li>The containing block of the <a data-link-type="dfn" title="root element">root
element’s</a> top-level boxes is a rectangle with the dimensions of
the <a data-link-type="dfn" href="#viewport0" id="ref-for-viewport0-1">viewport</a>, anchored at the <a data-link-type="dfn" href="#canvas" id="ref-for-canvas-3">canvas’s</a> origin for continuous media and the page area for paged media. (See <a data-link-type="biblio" href="#biblio-mediaq">[MEDIAQ]</a> and <a data-link-type="biblio" href="#biblio-css3page">[CSS3PAGE]</a> for definitions of continuous and paged
media.) This containing block is called the <dfn data-dfn-type="dfn" data-lt="initial containing block." data-noexport="" id="initial-containing-block">initial containing
block.<a class="self-link" href="#initial-containing-block"></a></dfn> The <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> and <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-writing-mode">writing-mode</a> of the initial
containing block are the same as those of the root element.
<li>
For other elements, the containing block is one of the
following:
<ol>
<li>If the element is a <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-run-in">run-in</a> that is rendered
inline in a sibling element, then its containing block
is the <a data-link-type="dfn">content edge</a> of the <a data-link-type="dfn" href="#principal-box" id="ref-for-principal-box-1">principal
box</a> of that sibling.
<li>Otherwise, if the parent has a <a data-link-type="dfn" href="#principal-box" id="ref-for-principal-box-2">principal
box</a> that is a <a data-link-type="dfn" href="#block-container-box" id="ref-for-block-container-box-1">block container box</a> (e.g., if the parent is a <a class="property" data-link-type="propdesc">table-cell</a> or a <a class="property" data-link-type="propdesc">block</a>),
then the containing block is the content edge of the
parent’s <a data-link-type="dfn">principal box.</a>
<li>Otherwise the containing block is the same as that
of the parent.
</ol>
</ul>
<p class="issue" id="issue-6ca12392"><a class="self-link" href="#issue-6ca12392"></a>Other modules may introduce other types of boxes with
other rules for how to find their containing block. E.g., the
containing block of an absolutely positioned element. </p>
<p>In the above, a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="block-container-box">block container box</dfn> is, informally, a
box that can contain block boxes. More precisely: any box generated by
a (pseudo-)element with a computed value for <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> of <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-block">block</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-inline-block">inline-block</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-table-caption">table-caption</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-table-cell">table-cell</a> or <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-list-item">list-item</a>. <span class="note" role="note">Note that most floating and absolutely
positioned elements have a computed <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> of <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-block">block</a>. Also, a <a data-link-type="dfn" href="#flow-root" id="ref-for-flow-root-2">flow root</a> has a computed <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> of <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-block">block</a>.</span> <span class="issue" id="issue-a1b431d2"><a class="self-link" href="#issue-a1b431d2"></a>Or insert the definition of block container box from
CSS 2.1 here?</span> </p>
<p class="issue" id="issue-267711dd"><a class="self-link" href="#issue-267711dd"></a>Also define <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="principal-box">principal box</dfn> somewhere. </p>
<p class="note" role="note">Note that the above is modified by the Absolute Positioning
module <a data-link-type="biblio" href="#biblio-css3pos">[CSS3POS]</a>: in particular, if a box’s <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-position">position</a> property is neither <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-position-3/#valdef-position-static">static</a> nor <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-position-3/#valdef-position-relative">relative</a>, its containing block is established
differently. </p>
<p>If an element <span class="issue" id="issue-a91659d4"><a class="self-link" href="#issue-a91659d4"></a>[or a viewport?]</span> has
scrollbars (see <a class="property" data-link-type="propdesc" href="#propdef-overflow" id="ref-for-propdef-overflow-1">overflow</a>), then any space taken up by the scrollbars
should be excluded from (subtracted from the dimensions of) any
containing block formed by that element. </p>
<h2 class="heading settled" data-level="5" id="flows"><span class="secno">5. </span><span class="content">Flows</span><a class="self-link" href="#flows"></a></h2>
<p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="flow">flow</dfn> (sometimes called <dfn data-dfn-type="dfn" data-noexport="" id="normal-flow">normal flow<a class="self-link" href="#normal-flow"></a></dfn>) is
one of the two basic kinds of layout in CSS, together with line layout <a data-link-type="biblio" href="#biblio-css3line">[CSS3LINE]</a>. It can be used, e.g., to layout a sequence of
paragraphs, headings, lists and floated elements in a single
column. Other CSS modules, such as tables <a data-link-type="biblio" href="#biblio-css3tbl">[CSS3TBL]</a>, positioning <a data-link-type="biblio" href="#biblio-css3pos">[CSS3POS]</a>, flex boxes <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a> and grid templates <a data-link-type="biblio" href="#biblio-css-template-3">[CSS-TEMPLATE-3]</a>, build on the flow model by defining ways to split a
document into more than one flow and positioning and aligning those
flows in various ways on the canvas. </p>
<p>A flow is constructed starting from a <span class="index" title="flow
root!!box">box</span> called the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="flow-root">flow root</dfn> by the <a href="#construct-flow">rules below.</a> We say the flow is <dfn data-dfn-type="dfn" data-noexport="" id="channeled">channeled<a class="self-link" href="#channeled"></a></dfn> by the flow root. </p>
<p class="issue" id="issue-28c5cd9d"><a class="self-link" href="#issue-28c5cd9d"></a>Are there more intuitive names than flow root? </p>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="initial-flow" title="initial flow|flow!!initial">initial flow<a class="self-link" href="#initial-flow"></a></dfn> is
the flow that contains the root of the box tree. </p>
<p>Despite not being a box, the <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#initial-containing-block">initial containing block</a> is
said to be the flow root of the initial flow. </p>
<p class="issue" id="pagination-issue"><a class="self-link" href="#pagination-issue"></a>How do we model pagination? If a
flow is broken over two pages or columns, do we call it a single flow
or two flows? I.e., is the page box the flow root of the flow, or is
the page box something else, more like the viewport, which influences
the layout of a flow but isn’t part of it? See <a data-link-type="biblio" href="#biblio-css3-break">[CSS3-BREAK]</a>. </p>
<p>Only <a data-link-type="dfn" href="#block-container-box" id="ref-for-block-container-box-2">block container boxes</a> (defined below) can be flow
roots. (Which implies that the children of a flow root are laid out in
a <a data-link-type="dfn">block formatting context.</a>) </p>
<p>Several (combinations of) properties cause an element to generate
boxes that are flow roots. This module defines a few. Other modules
may define more. </p>
<div class="note" role="note">
<p>For example, this module defines that any of the following make a
box into a flow root: </p>
<ul>
<li>The value of <a class="property" data-link-type="propdesc" href="#propdef-float" id="ref-for-propdef-float-1">float</a> is not <a class="property" data-link-type="propdesc">none</a>.
<li>The used value of <a class="property" data-link-type="propdesc" href="#propdef-overflow" id="ref-for-propdef-overflow-2">overflow</a> is not <a class="property" data-link-type="propdesc">visible</a>.
<li>The box is <a data-link-type="dfn" href="#vertical" id="ref-for-vertical-3">vertical</a> and its parent is <a data-link-type="dfn">horizontal.</a> <span class="issue" id="issue-893788bf"><a class="self-link" href="#issue-893788bf"></a>[Add link to the relevant
section.]</span>
<li>The box is <a data-link-type="dfn" href="#horizontal" id="ref-for-horizontal-4">horizontal</a> and its parent is <a data-link-type="dfn">vertical.</a>
</ul>
<p>Other examples: The table layout module <a data-link-type="biblio" href="#biblio-css3tbl">[CSS3TBL]</a> defines that a
table cell generates a box that is a flow root; the positioning module <a data-link-type="biblio" href="#biblio-css3pos">[CSS3POS]</a> defines that an absolutely positioned element generates a
flow root; the grid template module <a data-link-type="biblio" href="#biblio-css-template-3">[CSS-TEMPLATE-3]</a> defines that a
template element generate several flow roots; and the transforms
module <a data-link-type="biblio" href="#biblio-css3-transforms">[CSS3-TRANSFORMS]</a> defines that an element with a transform
generates a flow root. </p>
</div>
<p class="mtb" id="construct-flow">The flow of a given <a data-link-type="dfn" href="#flow-root" id="ref-for-flow-root-3">flow root</a> is a set of boxes. A box belongs to the flow if all of the following
are true: </p>
<ol>
<li>The used value of <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-block">block</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-list-item">list-item</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-table">table</a> or <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-flexbox-1/#valdef-display-flex">flex</a>.
<li>The used value of <a class="property" data-link-type="propdesc" href="#propdef-float" id="ref-for-propdef-float-2">float</a> is <a class="css" data-link-type="maybe" href="#valdef-clear-after-none" id="ref-for-valdef-clear-after-none-1">none</a>.
<li>The used value of <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-position">position</a> is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-position-3/#valdef-position-static">static</a> or <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-position-3/#valdef-position-relative">relative</a>.
<li>The used value of <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-regions-1/#propdef-flow-into">flow-into</a> <a data-link-type="biblio" href="#biblio-css3-regions">[CSS3-REGIONS]</a> <span class="issue" id="issue-6aa88308"><a class="self-link" href="#issue-6aa88308"></a>a.k.a. <a class="property" data-link-type="propdesc">flow</a> <a data-link-type="biblio" href="#biblio-css-template-3">[CSS-TEMPLATE-3]</a></span> is <a class="css" data-link-type="maybe" href="#valdef-clear-after-none" id="ref-for-valdef-clear-after-none-2">none</a>.
<li>It is not a <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-item">flex item</a> <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a>.
<li>It is either a child of the flow root or a child of a box that
belongs to the flow.
</ol>
<p class="note" role="note">Note that the flow root is itself not part of the flow
it channels and that each flow root channels at most one flow. </p>
<p class="note" role="note">Note that the last rule above implies that a flow with
its flow root together are always a connected subset of the box
tree. In other words; together, they form a subtree of the box tree
with possibly some branches removed. </p>
<p class="note" role="note">Note that the element tree and the box tree are not
necessarily parallel: the element a box belongs to need not be the
child of the element that generated the box’s parent. E.g., run-in
elements may generate boxes that become children of boxes from sibling
elements; and the <a class="property" data-link-type="propdesc">flow</a> property <a data-link-type="biblio" href="#biblio-css-template-3">[CSS-TEMPLATE-3]</a> and the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-position">position</a> property <a data-link-type="biblio" href="#biblio-css3pos">[CSS3POS]</a> may cause an element to generate a box that
becomes the child of a box from a grandparent or other ancestor
element. E.g., 'DIV {flow: b}' (see <a data-link-type="biblio" href="#biblio-css-template-3">[CSS-TEMPLATE-3]</a>) makes the DIV
generate boxes that become children of the box generated by slot b in
some ancestor. And 'DIV {position: absolute}' causes the DIV to
generate a box that becomes a child of the box generated by the
ancestor that established the DIV’s <a data-link-type="dfn">containing block.</a> </p>
<div class="example" id="example-df500c98">
<a class="self-link" href="#example-df500c98"></a>
<p>For example, the fragment </p>
<pre><div class=sidebar>
<p>Text in a sidebar.
<p>Here is quote:
<blockquote lang=ja>
<p>...
</blockquote>
<p>Etc. etc.
</div>
</pre>
<p>with the style </p>
<pre>div.sidebar { writing-mode: horizontal-tb; float: left }
blockquote[lang|=ja] { writing-mode: vertical-rl; height: 10em }
</pre>
<p>defines two flows: </p>
<ol>
<li>The <code>div</code> is a flow root, because it floats. Its flow
consist of the 1st, 2nd and 4th <code>p</code> and the <code>blockquote</code>.
<li>The <code>blockquote</code> is an <a data-link-type="dfn" href="#orthogonal" id="ref-for-orthogonal-1">orthogonal</a> element
(in this case a <a data-link-type="dfn" href="#vertical" id="ref-for-vertical-4">vertical</a> box inside a <a data-link-type="dfn" href="#horizontal" id="ref-for-horizontal-5">horizontal</a> parent) and it is thus a flow root. Its flow is formed by the 3rd <code>p</code>.
</ol>
<p>(The <code>div</code> itself belongs to a third flow, but its flow
root is not shown in the fragment.) </p>
</div>
<p class="note" role="note">Note that a flow root is not necessarily block-level, it may
be an <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-inline-block">inline-block</a>, e.g. </p>
<p class="note" role="note">Note that a box belongs to at most one flow. (Some boxes
do not belong to any flow, because they are part of a different kind of
layout, such as table layout.) </p>
<p>An element that generates a flow root box is itself also called a <span class="index" title="flow root!!element">flow root.</span> </p>
<p class="note" role="note">Note: The terminology in the CSS level 2 specification
is different. A flow root is called “an element that establishes a <span class="index" title="formatting context|new formatting
context">new formatting context.</span>” </p>
<p class="note" role="note">A consequence of this terminology is that an <em>element,</em> unlike a box, can be the flow root of several
flows. E.g., template elements <a data-link-type="biblio" href="#biblio-css-template-3">[CSS-TEMPLATE-3]</a> generate several flow
root boxes. Depending on what properties are set on a list item and on
its marker pseudo-element, a list item can also generate zero, one or
two flow roots. </p>
<h2 class="heading settled" data-level="6" id="boxes"><span class="secno">6. </span><span class="content">Types of boxes</span><a class="self-link" href="#boxes"></a></h2>
<p>The layout of boxes in the flow is in large part determined by the
interplay of the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> properties of an element and its parent,
and then fine-tuned with margins and padding. </p>
<h3 class="heading settled" data-level="6.1" id="block-level-cb-flows"><span class="secno">6.1. </span><span class="content">Block-level boxes, containing blocks
and anonymous boxes</span><a class="self-link" href="#block-level-cb-flows"></a></h3>
<p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="block-level">block-level</dfn> box is a box that has a <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-4/#computed-value">computed
value</a> for <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> of <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-block">block</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-list-item">list-item</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-table">table</a>, <span class="css">table-*</span> (i.e., all table boxes, see <a data-link-type="biblio" href="#biblio-css3tbl">[CSS3TBL]</a>), <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-run-in">run-in</a> (under
certain circumstances), or <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-gcpm-3/#footnote-display-compact">compact</a> (under certain circumstances). </p>
<p>An <dfn data-dfn-type="dfn" data-noexport="" id="inline-level">inline-level<a class="self-link" href="#inline-level"></a></dfn> box is a box that has a <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-4/#computed-value">computed
value</a> for <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> of <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-scroll-snap-1/#valdef-scroll-snap-type-inline">inline</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-inline-block">inline-block</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-inline-table">inline-table</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-ruby-1/#valdef-display-ruby">ruby</a>, <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-run-in">run-in</a> (under certain circumstances),
or <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-gcpm-3/#footnote-display-compact">compact</a> (under certain circumstances). </p>
<p class="issue" id="issue-aedfb759"><a class="self-link" href="#issue-aedfb759"></a>[What about the other ruby values?] </p>
<p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="anonymous-box">anonymous box,</dfn> informally, is a box that cannot be addressed
with CSS selectors. All its properties, except for <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a>, have their
default values (either the initial value or inherited). Anonymous boxes are
created when the CSS box model requires a child box with a certain value for <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a>, but the child actually has a different value. In that case an
anonymous box of the right kind is created and wraps the child (or children). </p>
<p>This module defines one kind of anonymous box: </p>
<p>A <a data-link-type="dfn">block-level box</a> may contain either <a data-link-type="dfn">line boxes</a> or <a data-link-type="dfn" href="#block-level" id="ref-for-block-level-1">block-level</a> boxes, but not both. If necessary, any line boxes
that belong to this box’s element are wrapped in one or more (as few
as possible) anonymous boxes with a <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-display-3/#propdef-display">display</a> of <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-display-3/#valdef-display-block">block</a>. </p>
<p>Other modules (e.g., <a data-link-type="biblio" href="#biblio-css3tbl">[CSS3TBL]</a>, <a data-link-type="biblio" href="#biblio-css3text">[CSS3TEXT]</a>) may also define
anonymous boxes. </p>
<div class="example" id="example-0bff9050">
<a class="self-link" href="#example-0bff9050"></a>
<p>An example of anonymous boxes is this document fragment: </p>
<pre><p>Somebody whose name I haveforgotten, said, long ago: <q>a box is
a box,</q> and he probably meant it.</p></pre>
<p>with these style rules: </p>
<pre>p { display: block }q { display: block; margin: 1em }</pre>
<p>The <code>p</code> element has both line boxes and a child box for the <code>q</code> element, which is a block-level element. The line boxes before
the <code>q</code> are wrapped in an anonymous block-level box and so are the
line boxes after the <code>q</code>. The resulting tree of boxes might be as
follows (refer to the <a href="#When">figure</a>): </p>
<ul>
<li>
block-level box [p]
<ul>
<li>
block-level box [anonymous]
<ul>
<li>line box: “Somebody…”
<li>line box: “forgotten…”
</ul>
<li>
block-level box [q]
<ul>
<li>line box: “a box…”
</ul>
<li>
block-level box [anonymous]
<ul>
<li>line box: “and he…”
</ul>
</ul>
</ul>
<div class="figure" id="When">
<p><img alt="The P element has two line boxes before the q and one
after. The first two are wrapped in an anonymous box, the last one
is wrapped in another anonymous box." src="anonymous.png"> </p>