forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.html
More file actions
8913 lines (6758 loc) · 322 KB
/
Overview.html
File metadata and controls
8913 lines (6758 loc) · 322 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 PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head
profile="http://dublincore.org/documents/2008/08/04/dc-html/ http://microformats.org/profile/h-card http://microformats.org/profile/hcard http://microformats.org/profile/rel-license "><!-- Note: the h-card profile is for a "microformats 2" vocabulary and
is experimental as of September 2012 -->
<meta content="text/html; charset=utf-8" http-equiv=content-type>
<title>CSS basic box model</title>
<link href="http://purl.org/dc/terms/" rel=schema.dcterms>
<link href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=dcterms.rights>
<meta content="CSS basic box model" name=dcterms.title>
<meta content=text name=dcterms.type>
<meta content=2013-01-23 name=dcterms.issued>
<meta content="Bert Bos" name=dcterms.creator>
<meta content="Anton Prowse" name=dcterms.creator>
<meta content=W3C name=dcterms.publisher>
<meta content="http://www.w3.org/TR/2013/ED-css3-box-20130123/"
name=dcterms.identifier>
<link href="../default.css" rel=stylesheet title=Default type="text/css">
<style type="text/css">
ol.stack p {margin-top: 0}
img.small {max-width: 100%}
.equiv-table tr {vertical-align: baseline}
.equiv-table img {max-width: 12em; max-width: 100%}
.minidiagram {height: 5em; vertical-align: middle}
/* Undo the max-width in the 2012 style for editor's drafts: */
body {max-width: none}
</style>
<link href="http://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>
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS basic box model</h1>
<h2 class="no-num no-toc" id=longstatus-date-26-sep-2006>Editor's Draft 23
January 2013</h2>
<dl>
<dt>This version:
<dd><a
href="http://www.w3.org/TR/2013/ED-css3-box-20130123/">http://www.w3.org/TR/2013/ED-css3-box-20130123</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-box">http://www.w3.org/TR/css3-box</a>
<dt>Previous version:
<dd><a
href="http://www.w3.org/TR/2002/WD-css3-box-20021024">http://www.w3.org/TR/2002/WD-css3-box-20021024</a>
<dt>Editors:
<dd class="h-card vcard"><a class="p-name fn u-url url"
href="http://www.w3.org/People/Bos/" rel=author>Bert Bos</a>, <span
class="p-org org">W3C</span>, <a class="u-email email"
href="mailto:bert@w3.org"><bert@w3.org></a>
<dd class="h-card vcard"><span class="p-name fn">Anton Prowse</span>,
<span class="p-org org">Invited Expert</span>, <a class="u-email email"
href="mailto:prowse@moonhenge.net"><prowse@moonhenge.net></a>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2013 <a href="http://www.w3.org/"><abbr
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><abbr
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
href="http://www.ercim.eu/"><abbr
title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p><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.
<h2 class="no-toc no-num" id=status-of-this-document>Status of this
document</h2>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcss3-box%5D%20PUT%20SUBJECT%20HERE">
www-style@w3.org</a> (see <a
href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
discussion of this specification. When sending e-mail, please put the text
“css3-box” in the subject, preferably like this:
“[<!---->css3-box<!---->] <em>…summary of comment…</em>”
<p>This document was produced by the <a href="/Style/CSS/members">CSS
Working Group</a> (part of the <a href="/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent
Policy</a>. W3C maintains a <a href="/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="/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the
W3C Patent Policy</a>.</p>
<!--end-status-->
<p>The CSS Working Group plans to ask for W3C Recommendation status for
this specification only when there are sufficiently many implementations.
See the section <a href="#exit">“CR exit criteria” </a> for details.
<p class=mtb>The terminology and the order of the sections is currently in
flux. This working draft is published to show the features that are being
discussed in the context of this module, but it is likely that some of the
names of the features will change.
<p>This module should eventually replace corresponding parts of the revised
CSS level 2 specification <a href="#CSS21"
rel=biblioentry>[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>
<h2 class="no-num no-toc" id=table-of-contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#how-to-read-this-specification"><span class=secno>1.
</span>How to read this specification</a>
<li><a href="#dependencies-on-other-modules"><span class=secno>2.
</span>Dependencies on other modules</a>
<li><a href="#introduction-amp-definitions"><span class=secno>3.
</span>Introduction & definitions</a>
<li><a href="#the-viewport-and-the-canvas"><span class=secno>4. </span>The
viewport and the canvas</a>
<li><a href="#flows"><span class=secno>5. </span>Flows</a>
<li><a href="#types-of-boxes"><span class=secno>6. </span>Types of
boxes</a>
<ul class=toc>
<li><a href="#display"><span class=secno>6.1. </span>The display
property</a>
<li><a href="#block-level-boxes-containing-blocks-flow"><span
class=secno>6.2. </span>Block-level boxes, containing blocks, flows and
anonymous boxes</a>
<li><a href="#run-in-boxes"><span class=secno>6.3. </span>Run-in
boxes</a>
<li><a href="#compact-boxes"><span class=secno>6.4. </span>Compact
boxes</a>
<li><a href="#container-box-or-align-box"><span class=secno>6.5.
</span>Container box <span class=issue>or: Align-box</span></a>
<li><a href="#mixing-the-box-model-with-other-formatti"><span
class=secno>6.6. </span>Mixing the box model with other formatting
models</a>
</ul>
<li><a href="#the-padding-properties"><span class=secno>7. </span>The
padding properties</a>
<li><a href="#the-margin-properties"><span class=secno>8. </span>The
margin properties</a>
<li><a href="#the-width-and-height-properties"><span class=secno>9.
</span>The width and height properties</a>
<li><a href="#min-max"><span class=secno>10. </span>The min-width,
max-width, min-height and max-height properties</a>
<li><a href="#intrinsic"><span class=secno>11. </span>Definition of
min-content/max-content</a>
<li><a href="#aspect-ratios-of-replaced-elements"><span class=secno>12.
</span>Aspect ratios of replaced elements</a>
<li><a href="#block-level-formatting"><span class=secno>13.
</span>Block-level formatting</a>
<ul class=toc>
<li><a href="#collapsing-margins"><span class=secno>13.1.
</span>Collapsing margins</a>
</ul>
<li><a href="#inline-level-formatting"><span class=secno>14.
</span>Inline-level formatting</a>
<li><a href="#Calculating"><span class=secno>15. </span>Calculating
widths, heights and margins</a>
<ul class=toc>
<li><a href="#inline-non-replaced"><span class=secno>15.1.
</span>Inline, non-replaced elements</a>
<li><a href="#inline-replaced"><span class=secno>15.2. </span>Inline or
floating, replaced elements</a>
<li><a href="#blockwidth"><span class=secno>15.3. </span>Block-level,
non-replaced elements in normal flow when ‘<code
class=property>overflow</code>’ computes to ‘<code
class=css>visible</code>’</a>
<li><a href="#other-block-level-non-replaced-elements-"><span
class=secno>15.4. </span>Other block-level, non-replaced elements in
normal flow</a>
<li><a href="#inline-block-or-floating-non-replaced-el"><span
class=secno>15.5. </span>‘<code class=property>Inline-block</code>’
or floating, non-replaced elements</a>
<li><a href="#abs-non-replaced-width"><span class=secno>15.6.
</span>Absolutely positioned, non-replaced elements</a>
<li><a href="#abs-replaced"><span class=secno>15.7. </span>Absolutely
positioned, replaced elements</a>
<li><a href="#block-level-replaced-elements-in-normal-"><span
class=secno>15.8. </span>Block-level, replaced elements in normal
flow</a>
<li><a href="#floating-non-replaced-elements"><span class=secno>15.9.
</span>Floating, non-replaced elements</a>
<li><a href="#root-height"><span class=secno>15.10. </span>Auto heights
for flow roots</a>
</ul>
<li><a href="#the-float-property"><span class=secno>16. </span>The float
property</a>
<ul class=toc>
<li><a href="#introduction-to-floats"><span class=secno>16.1.
</span>Introduction to floats</a>
<li><a href="#rules-for-positioning-floats"><span class=secno>16.2.
</span>Rules for positioning floats</a>
</ul>
<li><a href="#the-clear-property"><span class=secno>17. </span>The clear
property</a>
<li><a href="#the-clear-after-property"><span class=secno>18. </span>The
clear-after property</a>
<li><a href="#overflow0"><span class=secno>19. </span>Overflow</a>
<ul class=toc>
<li><a href="#overflow"><span class=secno>19.1. </span>The overflow,
overflow-x and overflow-y properties</a>
</ul>
<li><a href="#the-visibility-property"><span class=secno>20. </span>The
visibility property</a>
<li><a href="#the-alignment-property"><span class=secno>21. </span>The
alignment property</a>
<li><a href="#the-child-align-property"><span class=secno>22. </span>The
child-align property</a>
<li><a href="#stacking-contexts"><span class=secno>23. </span>Stacking
contexts</a>
<ul class=toc>
<li><a href="#definitions"><span class=secno>23.1.
</span>Definitions</a>
<li><a href="#painting-order"><span class=secno>23.2. </span>Painting
order</a>
<li><a href="#notes"><span class=secno>23.3. </span>Notes</a>
<li><a href="#the-ltnumbergt-value"><span class=secno>23.4. </span>The
<number> value</a>
<li><a href="#auto"><span class=secno>23.5. </span>The auto value</a>
<li><a href="#complex-size"><span class=secno>23.6. </span>Algorithm for
shrink-wrapping replaced elements with complex width/height</a>
</ul>
<li><a href="#the-float-displace-property"><span class=secno>24.
</span>The ‘<code class=property>float-displace</code>’ property</a>
<li><a href="#the-indent-edge-reset-property"><span class=secno>25.
</span>The ‘<code class=property>indent-edge-reset</code>’
property</a>
<li><a href="#conformance-and-profiles"><span class=secno>26.
</span>Conformance and profiles</a>
<li><a href="#exit"><span class=secno>27. </span>CR exit criteria</a>
<li><a href="#acknowledgments"><span class=secno>28.
</span>Acknowledgments</a>
<li class=no-num><a href="#references">References</a>
<li class=no-num><a href="#index">Index</a>
<li class=no-num><a href="#property-index">Property index</a>
</ul>
<!--end-toc-->
<h2 id=how-to-read-this-specification><span class=secno>1. </span>How to
read this specification</h2>
<p>All sections are normative, unless stated otherwise.
<div class=example>
<p>Examples look like this and normally start with the word “Example.”
Examples are not normative.
</div>
<p class=note>Notes look like this and normally start with the word
“Note.” Notes are not normative.
<p class=issue>Editorial notes look like this. They will be removed before
the document becomes Candidate Recommendation.
<p>Each property is defined in part in the text and in part by a table that
groups together a number of facts about the property, including a regular
expression to restrict its syntax. See <span class=issue>[where?]</span>
for the meaning. The “Inherited” and “Initial” rows in the table
are used by the Cascading and Inheritance module <a href="#CSS3CASCADE"
rel=biblioentry>[CSS3CASCADE]<!--{{CSS3CASCADE}}--></a> and “Media” by
the Media Queries specification <a href="#MEDIAQ"
rel=biblioentry>[MEDIAQ]<!--{{MEDIAQ}}--></a>.
<p>The specification may refer to the <a href="#used-value."><em>used
value</em></a> and the <a href="#computed-value"><em>computed
value</em></a> of a property. Unless stated explicitly, the short form
“value” means the computed value.
<h2 id=dependencies-on-other-modules><span class=secno>2.
</span>Dependencies on other modules</h2>
<p>This CSS module depends on the following other CSS modules:
<ul>
<li><cite>CSS Writing Modes Module</cite> <a href="#CSS3-WRITING-MODES"
rel=biblioentry>[CSS3-WRITING-MODES]<!--{{!CSS3-WRITING-MODES}}--></a>
– switch between vertical and horizontal text, properties <dfn
id=writing-mode>writing-mode</dfn> and <dfn id=direction>direction</dfn>,
definitions of the terms <dfn id=block-flow-direction>block flow
direction</dfn> and <dfn id=inline-base-direction.>inline base
direction.</dfn>
<li><cite>CSS Syntax Module</cite> <a href="#CSS3SYN"
rel=biblioentry>[CSS3SYN]<!--{{!CSS3SYN}}--></a> – syntax of properties
and values
<li><cite>CSS Values and Units Module</cite> <a href="#CSS3VAL"
rel=biblioentry>[CSS3VAL]<!--{{!CSS3VAL}}--></a> – definitions of value
types <dfn id=ltnumbergt><var><number></var></dfn>, <dfn
id=ltpercentagegt><var><percentage></var></dfn>, <dfn
id=ltanglegt><var><angle></var></dfn> and <dfn
id=ltlengthgt><var><length></var></dfn>; defines the terms <dfn
id=computed-value>computed value</dfn> and <dfn id=used-value.>used
value.</dfn>
<li><cite>CSS Text Module</cite> <a href="#CSS3TEXT"
rel=biblioentry>[CSS3TEXT]<!--{{!CSS3TEXT}}--></a> – inline layout and
definition of <dfn id=line-box.>line box.</dfn>
<li><cite>CSS Generated and Replaced Content module</cite> <a
href="#CSS3GENCON" rel=biblioentry>[CSS3GENCON]<!--{{!CSS3GENCON}}--></a>
– defines the terms <dfn id=replaced-element>replaced element</dfn> and
<dfn id=intrinsic0>intrinsic</dfn> size (and intrinsic ratio).
<li><cite>CSS Backgrounds and Borders Module</cite> <a href="#CSS3BG"
rel=biblioentry>[CSS3BG]<!--{{!CSS3BG}}--></a> – defines <dfn
id=ltbg-positiongt><var><bg-position></var></dfn>
<li><cite>CSS Basic User Interface Module</cite> <a href="#CSS3UI"
rel=biblioentry>[CSS3UI]<!--{{!CSS3UI}}--></a> – defines <dfn
id=box-sizing>box-sizing</dfn>
<li><cite>CSS 2D Transforms</cite> <a href="#CSS3-2D-TRANSFORMS"
rel=biblioentry>[CSS3-2D-TRANSFORMS]<!--{{!CSS3-2D-TRANSFORMS}}--></a>
– defines <dfn id=transform>transform</dfn>
</ul>
<h2 id=introduction-amp-definitions><span class=secno>3.
</span>Introduction & definitions</h2>
<p class=issue>Investigate if it is possible to make a pseudo-element to
select anonymous boxes (‘<code class=css>::paragraph</code>’). See
minutes of 10 Aug 2011.
<p class=note>Note: The model in this specification differs from the model
described in the CSS level 2 specification <a href="#CSS21"
rel=biblioentry>[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>CSS assumes that the document to lay out is modeled as a <span
class=index id=tree
title="tree!!of elements|document tree|element tree">tree</span> of <dfn
id=elements. title=element>elements.</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 id=root-element.>root element.</dfn>
<p class=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>CSS describes how each element and each string of text is laid out by
transforming the document tree into a set of rectangular boxes, whose
size, position, and stacking level on the <a
href="#canvas"><em>canvas</em></a> depend on their properties. We say that
an element <dfn id=generates title="generated box">generates</dfn> one or
more boxes. There are numerous different types of boxes. <span
class=issue>[Or maybe only one? I.e., a block-level box is just a normal
box that happens to be generated by a block-level element?]</span> A block
box is like a paragraph; a line box is like a single line of text; and
inline boxes are like words inside a line.
<div class=issue>
<p>Define the <dfn id=box-tree. title="box tree|tree!!of boxes">box
tree.</dfn> (Is the space between words a kind of box as well, or a
spacer item? Is the current selection a box? Is there a defined order
among sibling boxes? If so, are bidi inline boxes ordered in reading
order or in visual order?)
<p>[Define the box tree before pagination and then describe how pagination
can break one box into two?] <!--
<ul>
<li>If the parent element is a list item, the boxes go into the
parent's block box, not the marker box.
<li>If the element is run-in, its boxes go either into a box of its
parent element, or into a box of a later sibling.
<li>The order of sibling boxes is always such that boxes that belong
to elements earlier in the document come before boxes of elements that
come later in the document.
<li>Note that 'position' can put a box into the box of an ancestor
(the one establishing the containing block) rather than a parent.
<li>Note that 'flow' puts boxes into a named flow root.
</ul>
-->
</div>
<p>When the specification says a box <var>A</var> <dfn
id=contains>contains</dfn> a box <var>B</var> it means <var>B</var> is a
child of <var>A</var> in the <a href="#box-tree."><em>box tree.</em></a>
Typically, box <var>B</var> is geometrically contained within box
<var>A</var> as well, but that need not be the case, because of, e.g.,
overflow or negative margins.
<p class=note>Note: The precise rules are below and in other modules, but
in summary, <span class=issue>[write something that helps convey the idea
of a flow, e.g.:]</span> a block-level box contains either other
block-level boxes (e.g., a section containing paragraphs, or a table
containing rows), or it contains line boxes (e.g., a paragraph containing
lines of text). A line box contains inline-level boxes (e.g., a line with
words in different styles). An inline-level box may contain either text
interspersed with more inline-level boxes, or it may contain a block-level
box (e.g., a small table that is rendered inline).
<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 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).
</div>
<div class=example>
<p>For example, a fragment of HTML such as
<pre><ul>
<li>The first item in the list.
<li>The second item.
</ul></pre>
<p>may result in <span class=issue>[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>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>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.
</div>
<p>Each box belongs to exactly one element. It is either <a
href="#generates" title="generated box">generated</a> directly by the
element, or it is an <a href="#anonymous-box"><em>anonymous box,</em></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 id=induced>induced,</dfn> rather
than generated, by the element it belongs to.
<p class=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 class=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>Remove this note? Do we actually use the
concept of “principal box” anywhere?</span>
<p>Properties are set on elements <a href="#CSS3CASCADE"
rel=biblioentry>[CSS3CASCADE]<!--{{!CSS3CASCADE}}--></a> and influence how
the element is turned into boxes. Every box has the same properties with
the same values as the element to which it belongs, except for anonymous
boxes: inheritable properties on anonymous boxes have the same value as
the element, while non-inheritable properties have the initial value. The
only property that boxes do not have is the ‘<a href="#display0"><code
class=property>display</code></a>’ property. <span class=issue>[Is this
useful? Or is it better to say that boxes are just rectangles with a
border, a background, a position, a bunch of other boxes inside, and a
reference to the element they belong to? They don't really have properties
then and it is only a convenience to say the “the box has a font
<var>X.</var>”</span>
<p>Boxes do not have specified values <a href="#CSS3CASCADE"
rel=biblioentry>[CSS3CASCADE]<!--{{!CSS3CASCADE}}--></a>, but they do have
computed, used and actual values.
<p class=note>Boxes are frequently referred to by their property values.
For example, a “floated box” is a box whose computed value of ‘<a
href="#float"><code class=property>float</code></a>’ is not ‘<code
class=css>none</code>’, and a “positioned box” is a box whose
computed value of ‘<code class=property>position</code>’ is not
‘<code class=css>static</code>’. However, terms such as
<em>block-level box,</em> <a href="#block-container-box"><em>block
container box</em></a> and <em>table box</em> describe characteristics
which cannot be deduced solely from a box's property values.
<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 class=caption>The various areas and edges of a typical box
</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 <a href="#collapse."><em
title=collapse>collapsing</em></a> (i.e., the actual margin between
adjacent boxes may be less than the sum of the boxes' individual margins).
<p>Each box has a <dfn id=content-area>content area</dfn> (a.k.a. <dfn
id=content-box>content box</dfn>). The rectangle that bounds this area is
the <dfn id=content-edge.>content edge.</dfn> Around the content area is
the <dfn id=padding-area>padding area</dfn> and its outside bounds are
called the <dfn id=padding-edge.>padding edge.</dfn> The padding area and
content area together form the <dfn id=padding-box.>padding box.</dfn>
Outside the padding is the <dfn id=border-area>border area</dfn> and the
outside boundary of that area is the <dfn id=border-edge.>border
edge.</dfn> The border area, padding area and content area together form
the <dfn id=border-box.>border box.</dfn> Finally, outside the border is
the <dfn id=margin-area>margin area</dfn> and its outer edge is the <dfn
id=margin-edge.>margin edge.</dfn>
<p>When the specification says that the padding or border is <dfn
id=ldquoabsentrdquo
title="absent|padding!!absent|border!!absent">“absent”</dfn> on some
side of the box, that means that its thickness is zero.
<p><a href="#line-box."><em title="line box">Line boxes</em></a> cannot
have any padding, border or margin, and therefore their margin edge,
border edge, padding edge and content edge all coincide.
<p class=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 class=note>Note that the edges always form rectangles, even if there is
a ‘<code class=property>border-radius</code>’ <a href="#CSS3BG"
rel=biblioentry>[CSS3BG]<!--{{CSS3BG}}--></a> or a shape <a
href="#CSS3-EXCLUSIONS"
rel=biblioentry>[CSS3-EXCLUSIONS]<!--{{CSS3-EXCLUSIONS}}--></a>.
<p>We say that a box or element is <dfn id=horizontal>horizontal</dfn> if
its ‘<a href="#writing-mode"><code
class=property>writing-mode</code></a>’ property is ‘<code
class=css>horizontal-tb</code>’, otherwise it is <dfn
id=vertical.>vertical.</dfn>
<div class=note>
<p>Note that there are theoretically eight possible orientations for text,
but CSS only defines six:
<table class=equiv-table style="table-layout: fixed; width: 100%">
<thead>
<tr>
<th>
<th>‘<code class=css>writing-mode: horizontal-tb</code>’
<th>‘<code class=css>writing-mode: vertical-rl</code>’
<th>‘<code class=css>writing-mode: vertical-lr</code>’
<tbody>
<tr>
<th>‘<code class=css>direction: ltr</code>’
<td>
<p>Text is written from left to right and paragraphs grow downwards
<p><img alt="" class=small src=horizontal.png>
<td>
<p>Text is written top to bottom and paragraphs grow to the left
<p><img alt="" class=small src=vertical.png>
<td>
<p>Text is written top to bottom and paragraphs grow to the right
<p><img alt="" class=small src=vertical-lr.png>
<tr>
<th>‘<code class=css>direction: rtl</code>’
<td>
<p>Text is written from right to left and paragraphs grow downwards
<p><img alt="" class=small src=horizontal-rtl.png>
<td>
<p>Text is written bottom to top and paragraphs grow to the left
<p><img alt="" class=small src=vertical-rtl.png>
<td>
<p>Text is written bottom to top and paragraphs grow to the right
<p><img alt="" class=small src=vertical-lr-rtl.png>
</table>
<p>There is no “horizontal-bt.” More information about ‘<a
href="#writing-mode"><code class=property>writing-mode</code></a>’ and
‘<a href="#direction"><code class=property>direction</code></a>’ can
be found in <a href="#CSS3-WRITING-MODES"
rel=biblioentry>[CSS3-WRITING-MODES]<!--{{!CSS3-WRITING-MODES}}--></a>.
</div>
<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 (head
edge, foot edge, start edge and end edge) 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 (block dimension and inline dimension) for
the width and height of a box.
<p class=issue>The names head and foot are under discussion. There is an
issue in <a href="#CSS3-WRITING-MODES"
rel=biblioentry>[CSS3-WRITING-MODES]<!--{{!CSS3-WRITING-MODES}}--></a>
that suggests some possible names: “head,” “before,”
“before-block,” “foot,” “tail,” “after” and
“after-block.”
<p>The <dfn id=head>head,</dfn> <dfn id=foot>foot,</dfn> <dfn
id=start>start</dfn> and <dfn id=end>end</dfn> edge of a box refer to the
top, right, bottom and left edges, depending on the ‘<a
href="#writing-mode"><code class=property>writing-mode</code></a>’ and
‘<a href="#direction"><code class=property>direction</code></a>’
properties of that box, as follows:
<table class=equiv-table>
<thead>
<tr>
<th rowspan=2>Value of<br>
‘<a href="#writing-mode"><code
class=property>writing-mode</code></a>’
<th rowspan=2>Value of<br>
‘<a href="#direction"><code class=property>direction</code></a>’
<th colspan=4>Meaning of…
<th rowspan=2>
<tr>
<th>“head”
<th>“end”
<th>“foot”
<th>“start”
<tbody>
<tr>
<th rowspan=2>‘<code class=css>horizontal-tb</code>’
<th>‘<code class=css>ltr</code>’
<td>top
<td>right
<td>bottom
<td>left
<td><img alt="" class=minidiagram src=box-tb-ltr.svg>
<tr><!-- horizontal-tb -->
<th>‘<code class=css>rtl</code>’
<td>top
<td>left
<td>bottom
<td>right
<td><img alt="" class=minidiagram src=box-tb-rtl.svg>
<tr>
<th rowspan=2>‘<code class=css>vertical-rl</code>’
<th>‘<code class=css>ltr</code>’
<td>right
<td>bottom
<td>left
<td>top
<td><img alt="" class=minidiagram src=box-rl-ltr.svg>
<tr><!-- vertical-rl'' -->
<th>‘<code class=css>rtl</code>’
<td>right
<td>top
<td>left
<td>bottom
<td><img alt="" class=minidiagram src=box-rl-rtl.svg>
<tr>
<th rowspan=2>‘<code class=css>vertical-lr</code>’
<th>‘<code class=css>ltr</code>’
<td>left
<td>bottom
<td>right
<td>top
<td><img alt="" class=minidiagram src=box-lr-ltr.svg>
<tr><!-- vertical-lr -->
<th>‘<code class=css>rtl</code>’
<td>left
<td>top
<td>right
<td>bottom
<td><img alt="" class=minidiagram src=box-lr-rtl.svg>
</table>
<p class=note>For example, the “head padding” by default refers to the
‘<a href="#padding-top"><code class=property>padding-top</code></a>’
and the “end border” is by default the ‘<code
class=property>border-right</code>’.
<p>Similarly, the specification sometimes refers to the <dfn
id=inline-dimension>inline dimension</dfn> and <dfn
id=block-dimension>block dimension</dfn> of a box, instead of width and
height, as follows:
<table class=equiv-table>
<tbody>
<tr>
<th>‘<code class=css>Writing mode</code>’
<th>Meaning of “inline dimension”
<th>Meaning of “block dimension”
<tr>
<td>‘<code class=css>horizontal-tb</code>’
<td>width
<td>height
<tr>
<td>‘<code class=css>vertical-rl</code>’
<td>height
<td>width
<tr>
<td>‘<code class=css>vertical-lr</code>’
<td>height
<td>width
</table>
<p>These correspond to the dimensions in the <a
href="#inline-base-direction."><em>inline base direction</em></a> and the
<a href="#block-flow-direction"><em>block flow direction,</em></a>
respectively.
<p>An alternative term for the inline dimension is <dfn id=logical-width
title="logical width|width!!logical">logical width</dfn> and an
alternative term for block dimension is <dfn id=logical-height.
title="logical height|height!!logical">logical height.</dfn> These terms
occasionally occur in other CSS modules.
<p class=note>The block dimension of a box is thus the distance between the
head and foot edges, while the inline dimension of the box is the distance
between the start and end edges.
<p>When boxes are laid out in sequence to form a <a href="#flow0"><em
class=index id=flow>flow</em></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
id=a-edge>A edge,</dfn> <dfn id=b-edge>B edge,</dfn> <dfn id=c-edge>C
edge</dfn> and <dfn id=d-edge.>D edge.</dfn> They depend on the ‘<a
href="#writing-mode"><code class=property>writing-mode</code></a>’ and
‘<a href="#direction"><code class=property>direction</code></a>’
properties of the box's <a href="#containing-block0"><em class=index
id=containing-block>containing block</em></a> (defined below), and map to
the four sides as follows:
<table class=equiv-table>
<thead>
<tr>
<th rowspan=2>‘<a href="#writing-mode"><code
class=property>writing-mode</code></a>’ of<br>
<a href="#containing-block0"><em>containing block</em></a>
<th rowspan=2>‘<a href="#direction"><code
class=property>direction</code></a>’ of<br>
<a href="#containing-block0"><em>containing block</em></a>
<th colspan=4>Meaning of…
<tr>
<th>“A”
<th>“B”
<th>“C”
<th>“D”
<tbody>
<tr>
<th rowspan=2>‘<code class=css>horizontal-tb</code>’
<th>‘<code class=css>ltr</code>’
<td>top
<td>right
<td>bottom
<td>left
<tr><!-- horizontal-tb -->
<th>‘<code class=css>rtl</code>’
<td>top
<td>left
<td>bottom
<td>right
<tr>
<th rowspan=2>‘<code class=css>vertical-rl</code>’
<th>‘<code class=css>ltr</code>’
<td>right
<td>bottom
<td>left
<td>top
<tr><!-- vertical-rl -->
<th>‘<code class=css>rtl</code>’
<td>right
<td>top
<td>left
<td>bottom
<tr>
<th rowspan=2>‘<code class=css>vertical-lr</code>’
<th>‘<code class=css>rtl</code>’
<td>left
<td>bottom