-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
4130 lines (2707 loc) · 208 KB
/
Overview.html
File metadata and controls
4130 lines (2707 loc) · 208 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 Positioned Layout Module Level 3</title>
<meta content="exploring" name="csswg-work-status">
<meta content="ED" name="w3c-status">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<meta content="Bikeshed 1.0.0" name="generator">
<style type="text/css">
.cb-example-table {
border: 1px solid;
border-collapse: collapse;
font-size: smaller;
text-align: center;
margin: 0 2em;
}
.cb-example-table td, .cb-example-table th {
border: 1px solid;
padding: 0 3px;
}
code span, td span {
white-space: nowrap;
}
.relationship-table {
border: 1px solid;
border-collapse: collapse;
font-size: smaller;
margin: 0 6em;
}
.relationship-table th {
text-align: center;
white-space:nowrap;
}
.relationship-table td, .relationship-table th {
border: 1px solid;
padding: 0 3px;
}
h2 dfn, h3 dfn {
font: inherit;
}
table.lpr {
border-collapse: collapse;
}
.lpr td, .lpr th {
border: 1px solid;
text-align: center;
}
.lpr col {
background: rgb(221, 238, 255);
border-right: 2px solid;
font-weight: bold;
padding: 0 5px;
}
.lpr div {
font-weight: bold;
-moz-transform: rotate(-90deg) translatex(-0.5em);
-ms-transform: rotate(-90deg) translatex(-0.5em);
-o-transform: rotate(-90deg) translatex(-0.5em);
-webkit-transform: rotate(-90deg) translatex(-0.5em);
transform: rotate(-90deg) translatex(-0.5em);
width: 1.5em;
}
.lpr th:first-child {
border: none;
background: white;
}
.lpr tbody td:first-child {
font-weight: normal;
}
.lpr thead td {
background: rgb(238, 238, 238);
font-weight: bold;
padding: 0 5px;
vertical-align: bottom;
white-space: nowrap;
}
.lpr thead tr:nth-child(2) {
border-bottom: 2px solid;
}
</style>
<style>.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #708090 } /* Comment */
.highlight .k { color: #990055 } /* Keyword */
.highlight .l { color: #669900 } /* Literal */
.highlight .n { color: #0077aa } /* Name */
.highlight .o { color: #999999 } /* Operator */
.highlight .p { color: #999999 } /* Punctuation */
.highlight .cm { color: #708090 } /* Comment.Multiline */
.highlight .cp { color: #708090 } /* Comment.Preproc */
.highlight .c1 { color: #708090 } /* Comment.Single */
.highlight .cs { color: #708090 } /* Comment.Special */
.highlight .kc { color: #990055 } /* Keyword.Constant */
.highlight .kd { color: #990055 } /* Keyword.Declaration */
.highlight .kn { color: #990055 } /* Keyword.Namespace */
.highlight .kp { color: #990055 } /* Keyword.Pseudo */
.highlight .kr { color: #990055 } /* Keyword.Reserved */
.highlight .kt { color: #990055 } /* Keyword.Type */
.highlight .ld { color: #669900 } /* Literal.Date */
.highlight .m { color: #990055 } /* Literal.Number */
.highlight .s { color: #669900 } /* Literal.String */
.highlight .na { color: #0077aa } /* Name.Attribute */
.highlight .nc { color: #0077aa } /* Name.Class */
.highlight .no { color: #0077aa } /* Name.Constant */
.highlight .nd { color: #0077aa } /* Name.Decorator */
.highlight .ni { color: #0077aa } /* Name.Entity */
.highlight .ne { color: #0077aa } /* Name.Exception */
.highlight .nf { color: #0077aa } /* Name.Function */
.highlight .nl { color: #0077aa } /* Name.Label */
.highlight .nn { color: #0077aa } /* Name.Namespace */
.highlight .py { color: #0077aa } /* Name.Property */
.highlight .nt { color: #0077aa } /* Name.Tag */
.highlight .nv { color: #0077aa } /* Name.Variable */
.highlight .ow { color: #999999 } /* Operator.Word */
.highlight .mb { color: #990055 } /* Literal.Number.Bin */
.highlight .mf { color: #990055 } /* Literal.Number.Float */
.highlight .mh { color: #990055 } /* Literal.Number.Hex */
.highlight .mi { color: #990055 } /* Literal.Number.Integer */
.highlight .mo { color: #990055 } /* Literal.Number.Oct */
.highlight .sb { color: #669900 } /* Literal.String.Backtick */
.highlight .sc { color: #669900 } /* Literal.String.Char */
.highlight .sd { color: #669900 } /* Literal.String.Doc */
.highlight .s2 { color: #669900 } /* Literal.String.Double */
.highlight .se { color: #669900 } /* Literal.String.Escape */
.highlight .sh { color: #669900 } /* Literal.String.Heredoc */
.highlight .si { color: #669900 } /* Literal.String.Interpol */
.highlight .sx { color: #669900 } /* Literal.String.Other */
.highlight .sr { color: #669900 } /* Literal.String.Regex */
.highlight .s1 { color: #669900 } /* Literal.String.Single */
.highlight .ss { color: #669900 } /* Literal.String.Symbol */
.highlight .vc { color: #0077aa } /* Name.Variable.Class */
.highlight .vg { color: #0077aa } /* Name.Variable.Global */
.highlight .vi { color: #0077aa } /* Name.Variable.Instance */
.highlight .il { color: #990055 } /* Literal.Number.Integer.Long */
.highlight { background: hsl(24, 20%, 95%); }
pre.highlight { padding: 1em; margin: .5em 0; overflow: auto; }
:not(pre).highlight { padding: .1em; border-radius: .3em; }
</style>
</head>
<body class="h-entry">
<div class="head">
<p data-fill-with="logo"><a class="logo" href="http://www.w3.org/">
<img alt="W3C" height="48" src="https://www.w3.org/Icons/w3c_home" width="72">
</a>
</p>
<h1 class="p-name no-ref" id="title">CSS Positioned Layout Module Level 3</h1>
<h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">Editor’s Draft,
<time class="dt-updated" datetime="2015-07-22">22 July 2015</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-position/">http://dev.w3.org/csswg/css-position/</a>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css3-positioning/">http://www.w3.org/TR/css3-positioning/</a>
<dt>Previous Versions:
<dd><a href="http://www.w3.org/TR/2012/WD-css3-positioning-20120207/" rel="previous">http://www.w3.org/TR/2012/WD-css3-positioning-20120207/</a>
<dt>Feedback:
<dd><span><a href="mailto:www-style@w3.org?subject=%5Bcss-position%5D%20YOUR%20TOPIC%20HERE">www-style@w3.org</a> with subject line “<kbd>[css-position] <var>… message topic …</var></kbd>” (<a href="http://lists.w3.org/Archives/Public/www-style/" rel="discussion">archives</a>)</span>
<dt>Issue Tracking:
<dd><a href="https://github.com/w3c/csswg-drafts/issues/">GitHub</a>
<dd><a href="#issues-index">Inline In Spec</a>
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:ratan@microsoft.com">Rossen Atanassov</a> (<span class="p-org org">Microsoft</span>)
<dd class="editor p-author h-card vcard"><a class="p-name fn u-email email" href="mailto:arronei@microsoft.com">Arron Eicholz</a> (<span class="p-org org">Microsoft</span>)
<dt>Issues list:
<dd><span><a href="http://wiki.csswg.org/spec/css-position/">in Wiki</a></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> © 2015 <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>This module contains the features of CSS level 3 relating to positioning and stacking of elements. It includes and extends the functionality of CSS level 2 (<a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>), which builds on CSS level 1 <a data-link-type="biblio" href="#biblio-css1">[CSS1]</a>. The main extensions compared to level 2 are the ability to position elements based on CSS Region boxes, the ability to specify different containing blocks for elements and sticky positioning. </p>
<p>Other kinds of layout, such as tables, "floating" boxes, ruby annotations, grid layouts, columns and basic handling of normal "flow" content, are described in other modules. Also, the layout of text inside each line is defined elsewhere.</p>
<a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.</div>
<h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
</p>
<p>
The (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-position%5D%20PUT%20SUBJECT%20HERE">www-style@w3.org</a>
(see <a href="http://www.w3.org/Mail/Request">instructions</a>)
is preferred for discussion of this specification.
When sending e-mail,
please put the text “css-position” in the subject,
preferably like this:
“[css-position] <em>…summary of comment…</em>”
</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/2014/Process-20140801/" id="w3c_process_revision">1 August 2014 W3C Process Document</a>.
</p>
<p>
</p></div>
<div data-fill-with="at-risk"></div>
<h2 class="no-num no-toc no-ref heading settled" id="contents"><span class="content">Table of Contents</span></h2>
<div data-fill-with="table-of-contents" role="navigation">
<ul class="toc" role="directory">
<li><a href="#intro"><span class="secno">1</span> <span class="content">
Introduction</span></a>
<ul class="toc">
<li><a href="#placement"><span class="secno">1.1</span> <span class="content">
Module Interactions</span></a>
<li><a href="#values"><span class="secno">1.2</span> <span class="content">
Values</span></a>
</ul>
<li><a href="#vp"><span class="secno">2</span> <span class="content">
The <span>Viewport</span></span></a>
<li><a href="#cb"><span class="secno">3</span> <span class="content">
Containing Blocks</span></a>
<ul class="toc">
<li><a href="#def-cb"><span class="secno">3.1</span> <span class="content">
Definition of <span>containing block</span></span></a>
</ul>
<li><a href="#nf"><span class="secno">4</span> <span class="content">
<span>Normal Flow</span></span></a>
<li><a href="#floats"><span class="secno">5</span> <span class="content">
<span>Floats</span></span></a>
<li><a href="#pos-sch"><span class="secno">6</span> <span class="content">
<span>Positioning schemes</span></span></a>
<ul class="toc">
<li><a href="#rel-pos"><span class="secno">6.1</span> <span class="content">
Relative positioning</span></a>
<li><a href="#sticky-pos"><span class="secno">6.2</span> <span class="content">
Sticky positioning</span></a>
<li><a href="#abs-pos"><span class="secno">6.3</span> <span class="content">
Absolute positioning</span></a>
<li><a href="#fixed-pos"><span class="secno">6.4</span> <span class="content">
Fixed positioning</span></a>
<li><a href="#position-property"><span class="secno">6.5</span> <span class="content">
Choosing a positioning scheme: <span class="property">position</span> property</span></a>
<li><a href="#box-offsets-trbl"><span class="secno">6.6</span> <span class="content">
Box offsets: <span class="property">top</span>, <span class="property">right</span>, <span class="property">bottom</span>, <span class="property">left</span></span></a>
<li><a href="#logical-box-offsets-beaso"><span class="secno">6.7</span> <span class="content">
Logical box offsets: <span class="property">offset-before</span>, <span class="property">offset-end</span>, <span class="property">offset-after</span> and <span class="property">offset-start</span></span></a>
</ul>
<li><a href="#position-root"><span class="secno">7</span> <span class="content">
Choosing a different containing block for positioning</span></a>
<ul class="toc">
<li><a href="#attachment-properties"><span class="secno">7.1</span> <span class="content">
Attachment properties: <span class="property">attachment-type</span>, <span class="property">attachment-top</span>, <span class="property">attachment-right</span>, <span class="property">attachment-bottom</span>, <span class="property">attachment-left</span>, and <span class="property">attachment</span></span></a>
</ul>
<li><a href="#size-and-position-details"><span class="secno">8</span> <span class="content">
Sizing and positioning details</span></a>
<ul class="toc">
<li><a href="#abs-non-replaced-width"><span class="secno">8.1</span> <span class="content">
The width of absolute or fixed positioned, non-replaced elements</span></a>
<li><a href="#abs-replaced-width"><span class="secno">8.2</span> <span class="content">
The width of absolute or fixed positioned, replaced elements</span></a>
<li><a href="#abs-non-replaced-height"><span class="secno">8.3</span> <span class="content">
The height of absolute or fixed positioned, non-replaced elements</span></a>
<li><a href="#abs-replaced-height"><span class="secno">8.4</span> <span class="content">
The height of absolute or fixed positioned, replaced elements</span></a>
<li><a href="#root-height"><span class="secno">8.5</span> <span class="content">
Auto heights for block formatting context roots</span></a>
</ul>
<li><a href="#dis-pos-flo"><span class="secno">9</span> <span class="content">
Relationships between <span class="property">display</span>, <span class="property">position</span>, and <span class="property">float</span></span></a>
<li><a href="#comparison"><span class="secno">10</span> <span class="content">
Comparison of normal flow, floats, and positioning</span></a>
<ul class="toc">
<li><a href="#comp-normal-flow"><span class="secno">10.1</span> <span class="content">
Normal flow</span></a>
<li><a href="#comp-relpos"><span class="secno">10.2</span> <span class="content">
Relative positioning</span></a>
<li><a href="#comp-floating"><span class="secno">10.3</span> <span class="content">
Floating a box</span></a>
<li><a href="#comp-abspos"><span class="secno">10.4</span> <span class="content">
Absolute positioning</span></a>
</ul>
<li><a href="#layered-presentation"><span class="secno">11</span> <span class="content">
Layered presentation</span></a>
<li><a href="#det-stacking-context"><span class="secno">12</span> <span class="content">
Detailed stacking context</span></a>
<ul class="toc">
<li><a href="#definitions-stack"><span class="secno">12.1</span> <span class="content">
Definitions</span></a>
<li><a href="#painting-order"><span class="secno">12.2</span> <span class="content">
Painting order</span></a>
<li><a href="#stacking-notes"><span class="secno">12.3</span> <span class="content">
Notes</span></a>
</ul>
<li><a href="#ack"><span class="secno">13</span> <span class="content">
Acknowledgments</span></a>
<li><a href="#changes"><span class="secno"></span> <span class="content">Changes</span></a>
<ul class="toc">
<li><a href="#changes-201207"><span class="secno"></span> <span class="content">
Changes since the 7 February 2012 WD</span></a>
</ul>
<li><a href="#conformance"><span class="secno"></span> <span class="content">
Conformance</span></a>
<ul class="toc">
<li><a href="#conventions"><span class="secno"></span> <span class="content">
Document conventions</span></a>
<li><a href="#conformance-classes"><span class="secno"></span> <span class="content">
Conformance classes</span></a>
<li><a href="#partial"><span class="secno"></span> <span class="content">
Partial implementations</span></a>
<li><a href="#experimental"><span class="secno"></span> <span class="content">
Experimental implementations</span></a>
<li><a href="#testing"><span class="secno"></span> <span class="content">
Non-experimental implementations</span></a>
</ul>
<li><a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ul 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>
</ul>
<li><a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ul class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
</ul>
<li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a>
<li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
</ul></div>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content">
Introduction</span><a class="self-link" href="#intro"></a></h2>
<em>This section is not normative.</em>
<p>CSS assumes the document layout is modeled as a tree of elements. The unique
element that has no parent is called the root element. This module describes
how any of the elements from the tree of elements can be arranged independent
of document order (i.e. taken out of "flow"). With a positioned element the
element may be placed anywhere within the content not specifically respecting
the tree of elements order.</p>
<p>In <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>, the visual formatting model explained how each element in the
document tree generates zero or more boxes according to the box model. This
module further explains and extends the positioning scheme. The layout of
these boxes is governed by:</p>
<ul>
<li>
<a href="http://www.w3.org/TR/CSS2/box.html#box-dimensions">box dimensions</a>
and <a href="http://www.w3.org/TR/CSS2/visuren.html#box-gen">type</a>.
<li>
positioning scheme (<a data-link-type="dfn" href="#normal-flow">normal flow</a>, float, and absolute positioning).
<li>
relationships between elements in the
<a href="http://www.w3.org/TR/CSS2/conform.html#doctree">document tree</a>.
<li>
external information (e.g., viewport size, intrinsic dimensions of images, etc.).
</ul>
<p>The properties defined in this module apply to both continuous media and paged
media.</p>
<h3 class="heading settled" data-level="1.1" id="placement"><span class="secno">1.1. </span><span class="content">
Module Interactions</span><a class="self-link" href="#placement"></a></h3>
<p>This module replaced and extends the positioning scheme features defined in
<a data-link-type="biblio" href="#biblio-css21">[CSS21]</a> sections:</p>
<ul>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#viewport">9.1.1 The viewport</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#containing-block">9.1.2 Containing blocks</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#positioning-scheme">9.3 Positioning schemes</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#relative-positioning">9.4.3 Relative positioning</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#absolute-positioning">9.6 Absolute positioning</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo">9.7 Relationships between display, position, and float</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#comparison">9.8 Comparison of normal flow, floats, and absolute positioning</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visuren.html#layers">9.9 Layered presentation</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visudet.html#containing-block-details">10.1 Definition of "containing block"</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width">10.3.7 Absolutely positioned, non-replaced elements</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visudet.html#abs-replaced-width">10.3.8 Absolutely positioned, replaced elements</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-height">10.6.4 Absolutely positioned, non-replaced elements</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visudet.html#abs-replaced-height">10.6.5 Absolutely positioned replaced elements</a>
<li>
<a href="http://www.w3.org/TR/CSS2/visudet.html#root-height">10.6.7 Auto heights for block formatting context roots</a>
<li>
<a href="http://www.w3.org/TR/CSS2/zindex.html">Appendix E. Elaborate description of Stacking Contexts</a>
</ul>
<h3 class="heading settled" data-level="1.2" id="values"><span class="secno">1.2. </span><span class="content">
Values</span><a class="self-link" href="#values"></a></h3>
<p>This specification follows the CSS property definition conventions from <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>.</p>
<p>Value types not defined in this specification are defined in CSS Level 2
Revision 1 <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>. Other CSS modules may expand the definitions of these
value types: for example <a data-link-type="biblio" href="#biblio-css3val">[CSS3VAL]</a>, when combined with this module, expands
the definition of the <length> value type as used in this specification.</p>
<p>In addition to the property-specific values listed in their definitions, all
properties defined in this specification also accept the
<a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.</p>
<h2 class="heading settled" data-level="2" id="vp"><span class="secno">2. </span><span class="content">
The <dfn data-dfn-type="dfn" data-lt="viewport" data-noexport="" id="viewport">Viewport<a class="self-link" href="#viewport"></a></dfn></span><a class="self-link" href="#vp"></a></h2>
<p>User agents for <a href="http://www.w3.org/TR/CSS2/media.html#continuous-media-group">continuous media</a> generally offer users a viewport (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 <span>initial containing block</span>).</p>
<p>When the viewport is smaller than the area of the canvas on which the document
is rendered, the user agent may offer a scrolling mechanism. There is at most
one viewport per <a href="http://www.w3.org/TR/CSS2/intro.html#canvas">canvas</a>,
but user agents may render to more than one canvas (i.e., provide different
views of the same document).</p>
<h2 class="heading settled" data-level="3" id="cb"><span class="secno">3. </span><span class="content">
Containing Blocks</span><a class="self-link" href="#cb"></a></h2>
<p>In CSS, many box positions and sizes are calculated with respect to the edges
of a rectangular box called a containing block. In general, generated boxes
act as containing blocks for descendant boxes; we say that a box "establishes"
the containing block for its descendants. The phrase "a box’s containing
block" means "the containing block in which the box lives," not the one it
generates.</p>
<p>Each box is given a position with respect to its containing block, but it is
not confined by this containing block; it may
<a href="http://www.w3.org/TR/CSS2/visufx.html#overflow">overflow</a>.</p>
<h3 class="heading settled" data-level="3.1" id="def-cb"><span class="secno">3.1. </span><span class="content">
Definition of <dfn data-dfn-type="dfn" data-noexport="" id="containing-block">containing block<a class="self-link" href="#containing-block"></a></dfn></span><a class="self-link" href="#def-cb"></a></h3>
<p>The position and size of an element’s box(es) are sometimes computed relative
to a certain rectangle, called the containing block of the element. The containing
block of a <a class="css" data-link-type="maybe" href="#valdef-position-static">static</a> or
<a class="css" data-link-type="maybe" href="#valdef-position-relative">relative</a> element is defined
in the Box Model <a data-link-type="biblio" href="#biblio-css3box">[CSS3BOX]</a>. The containing block of a
<a class="css" data-link-type="maybe" href="#valdef-position-sticky">sticky</a> element is the same as for a
<a class="css" data-link-type="maybe" href="#valdef-position-relative">relative</a> element. For
<a class="css" data-link-type="maybe" href="#valdef-position-fixed">fixed</a> and
<a class="css" data-link-type="maybe" href="#valdef-position-absolute">absolute</a>, it is defined as follows:</p>
<ol>
<li>
If the element has <a class="css" data-link-type="propdesc" href="#propdef-position">position: fixed</a>, the containing block is established by the
<a data-link-type="dfn" href="#viewport">viewport</a> in the case of continuous media or the page area in
the case of paged media.
<li>
If the element has <a class="css" data-link-type="propdesc" href="#propdef-position">position: absolute</a>,
the containing block is established by the nearest ancestor with a <a class="property" data-link-type="propdesc" href="#propdef-position">position</a>
other than <a class="css" data-link-type="maybe" href="#valdef-position-static">static</a>, in the following way:
<ol>
<li>
In the case that the ancestor is block-level, the containing block is formed
by the padding edge of the ancestor.
<li>
In the case that the ancestor is inline-level, the containing block depends
on the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> property of the ancestor:
<ol>
<li>
If the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>, the top and left of the containing
block are the top and left content edges of the first box generated
by the ancestor, and the bottom and right are the bottom and right
content edges of the last box of the ancestor.
<li>
If the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>, the top and right are the
top and right edges of the first box generated by the ancestor, and
the bottom and left are the bottom and left content edges of the
last box of the ancestor.
<p class="note" role="note">
Note, in some cases when a line wraps it may seem as if the left
and right positions are swapped.
</p>
</ol>
</ol>
<li>
<li>
If there is no such ancestor, the containing block is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#initial-containing-block">initial
containing block</a>.
</ol>
<p>In paged media, an absolutely positioned element is positioned relative to its
containing block ignoring any page breaks (as if the document were continuous). The
element may subsequently be broken over several pages.</p>
<p>For absolutely positioned content that resolves to a position on a page other than the
page being laid out (the current page), or resolves to a position on the current page
which has already been rendered for printing, printers may place the content:</p>
<ul>
<li>on the current page,
<li>on a subsequent page, or
<li>may omit it altogether.
</ul>
<p class="note" role="note">
Note, a block-level element that is split over several pages may have a different width
on each page and that there may be device-specific limits.
</p>
<div class="example" id="example-362c0298"><a class="self-link" href="#example-362c0298"></a>
<p>With no positioning, the containing blocks (C.B.) in the following document:</p>
<pre><code class="html"><!DOCTYPE html>
<html>
<head>
<title>Illustration of containing blocks</title>
</head>
<body id="body">
<div id="div1">
<p id="p1">This is text in the first paragraph...</p>
<p id="p2">This is text <em id="em1"> in the
<strong id="strong1">second</strong> paragraph.</em></p>
</div>
</body>
</html>
</code></pre>
<p>are established as follows:</p>
<table class="cb-example-table">
<tbody>
<tr>
<th>For box generated by
<th>C.B. is established by
<tr>
<td>html
<td>initial C.B. (UA-dependent)
<tr>
<td>body
<td>html
<tr>
<td>div1
<td>body
<tr>
<td>p1
<td>div1
<tr>
<td>p2
<td>div1
<tr>
<td>em1
<td>p2
<tr>
<td>strong1
<td>p2
</table>
<p>If we position "div1":</p>
<pre><code>#div1 { position: absolute; left: 50px; top: 50px }
</code></pre>
<p>its containing block is no longer "body"; it becomes the <span>initial containing block</span>
(since there are no other positioned ancestor boxes).</p>
<p>If we position "em1" as well:</p>
<pre><code>#div1 { position: absolute; left: 50px; top: 50px }
#em1 { position: absolute; left: 100px; top: 100px }
</code></pre>
<p>the table of containing blocks becomes:</p>
<table class="cb-example-table">
<tbody>
<tr>
<th>For box generated by
<th>C.B. is established by
<tr>
<td>html
<td>initial C.B. (UA-dependent)
<tr>
<td>body
<td>html
<tr>
<td>div1
<td>initial C.B.
<tr>
<td>p1
<td>div1
<tr>
<td>p2
<td>div1
<tr>
<td>em1
<td>div1
<tr>
<td>strong1
<td>em1
</table>
<p>By positioning "em1", its containing block becomes the nearest positioned ancestor box
(i.e., that generated by "div1").</p>
</div>
<h2 class="heading settled" data-level="4" id="nf"><span class="secno">4. </span><span class="content">
<dfn data-dfn-type="dfn" data-noexport="" id="normal-flow">Normal Flow<a class="self-link" href="#normal-flow"></a></dfn></span><a class="self-link" href="#nf"></a></h2>
<p>Boxes in the normal flow belong to a formatting context, which may be block or
inline, but not both simultaneously. See the CSS Basic Box Model module
<a data-link-type="biblio" href="#biblio-css3box">[CSS3BOX]</a> for further details about <a href="http://www.w3.org/TR/CSS2/visuren.html#normal-flow">normal flow</a>.</p>
<h2 class="heading settled" data-level="5" id="floats"><span class="secno">5. </span><span class="content">
<dfn data-dfn-type="dfn" data-lt="float|floated box|floating box" data-noexport="" id="float">Floats<a class="self-link" href="#float"></a></dfn></span><a class="self-link" href="#floats"></a></h2>
<p>A float is a box that is positioned within content, often left or right on the
current line. The most interesting characteristic of a float (or "floated" or
"floating" box) is that inline-level content may flow along its side (or be
prohibited from doing so by the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visuren.html#propdef-clear">clear</a> property) or around the floated box.
See the CSS 2.1 <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a> for details
about <a href="http://www.w3.org/TR/CSS2/visuren.html#floats">floating boxes</a>.</p>
<h2 class="heading settled" data-level="6" id="pos-sch"><span class="secno">6. </span><span class="content">
<dfn data-dfn-type="dfn" data-noexport="" id="positioning-schemes">Positioning schemes<a class="self-link" href="#positioning-schemes"></a></dfn></span><a class="self-link" href="#pos-sch"></a></h2>
<p>In CSS, a box may be laid out according to three positioning schemes:</p>
<ol>
<li>
Normal flow<br>
In CSS, <a data-link-type="dfn" href="#normal-flow">normal flow</a> includes <a href="http://www.w3.org/TR/CSS2/visuren.html#block-formatting">block formatting</a> of block-level boxes,
<a href="http://www.w3.org/TR/CSS2/visuren.html#inline-formatting">inline formatting</a> of inline-level boxes,
and <a data-link-type="dfn" href="#relative-position">relative</a> and <a data-link-type="dfn" href="#sticky-position">sticky</a> positioning of block-level and inline-level boxes.
<li>
Floats<br>
In the <a data-link-type="dfn" href="#float">float</a> model, a box is first laid out according to the <a data-link-type="dfn" href="#normal-flow">normal flow</a>, then taken
out of the flow and positioned, typically to the left or right. Content may flow
along the side of a <a data-link-type="dfn" href="#float">float</a>.
<li>
Absolute positioning<br>
In the absolute positioning model, a box is removed from the <span>normal
flow</span> entirely (it has no impact on later siblings) and assigned a
position with respect to a <a data-link-type="dfn" href="#containing-block">containing block</a>.
</ol>
<p>An element is called <em>out-of-flow</em> if it is <a data-link-type="dfn" href="#float">floated</a>, absolutely positioned, or is the root element. An element is called
<em>in-flow</em> if it is not out-of-flow. The <em>flow of an element</em>
A is the set consisting of A and all in-flow elements whose nearest
out-of-flow ancestor is A.</p>
<h3 class="heading settled" data-level="6.1" id="rel-pos"><span class="secno">6.1. </span><span class="content">
Relative positioning</span><a class="self-link" href="#rel-pos"></a></h3>
<p>Once a box has been laid out according to the <a data-link-type="dfn" href="#normal-flow">normal flow</a> or
<a data-link-type="dfn" href="#float">floated</a>, it may be offset relative to this position.
This is called <dfn data-dfn-type="dfn" data-export="" data-lt="relative position|relatively position|relpos" id="relative-position">relative positioning<a class="self-link" href="#relative-position"></a></dfn>. Offsetting a box (B1) in this way has no
effect on the box (B2) that follows: B2 is given a position as if B1 were not
offset and B2 is not re-positioned after B1’s offset is applied. This
implies that relative positioning may cause boxes to overlap. However, if
relative positioning causes an 'overflow: auto' or 'overflow: scroll' box to
have overflow, the user agent must allow the user to access this content (at
its offset position), which, through the creation of a scrolling mechanism,
may affect layout.</p>
<p>A relatively positioned box keeps its <a data-link-type="dfn" href="#normal-flow">normal flow</a> size, including
line breaks and the space originally reserved for it.</p>
<p>A relatively positioned box establishes a new a new <a data-link-type="dfn" href="#containing-block">containing block</a> for
absolutely positioned descendants. (This is a common use of relatively positioned
boxes.) The section on <a data-link-type="dfn" href="#containing-block">containing blocks</a>
explains when a relatively positioned box establishes a new <a data-link-type="dfn" href="#containing-block">containing block</a>.</p>
<p>For relatively positioned elements, <a class="property" data-link-type="propdesc" href="#propdef-left">left</a> and <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> move the box(es) horizontally,
without changing their size. <a class="property" data-link-type="propdesc" href="#propdef-left">Left</a> moves the boxes to the right, and <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> moves
them to the left. Since boxes are not split or stretched as a result of <a class="property" data-link-type="propdesc" href="#propdef-left">left</a> or
<a class="property" data-link-type="propdesc" href="#propdef-right">right</a>, the used values are always: left = -right.</p>
<p>If both <a class="property" data-link-type="propdesc" href="#propdef-left">left</a> and <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> are <span class="css">auto</span> (their initial values), the used values
are <span class="css">0</span> (i.e., the boxes stay in their original position).</p>
<p>If <a class="property" data-link-type="propdesc" href="#propdef-left">left</a> is <span class="css">auto</span>, its used value is minus the value of <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> (i.e., the
boxes move to the left by the value of <a class="property" data-link-type="propdesc" href="#propdef-right">right</a>).</p>
<p>If <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> is specified as <span class="css">auto</span>, its used value is minus the value of <a class="property" data-link-type="propdesc" href="#propdef-left">left</a>.</p>
<p>If neither <a class="property" data-link-type="propdesc" href="#propdef-left">left</a> nor <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> is <span class="css">auto</span>, the position is over-constrained, and
one of them has to be ignored. If the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> property of the <a data-link-type="dfn" href="#containing-block">containing
block</a> is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-ltr">ltr</a>, the value of <a class="property" data-link-type="propdesc" href="#propdef-left">left</a> wins and <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> becomes -<a class="property" data-link-type="propdesc" href="#propdef-left">left</a>.
If <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-writing-modes-3/#propdef-direction">direction</a> of the containing block is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-writing-modes-3/#valdef-direction-rtl">rtl</a>, <a class="property" data-link-type="propdesc" href="#propdef-right">right</a> wins and <a class="property" data-link-type="propdesc" href="#propdef-left">left</a> is
ignored.</p>
<div class="example" id="example-773b931f"><a class="self-link" href="#example-773b931f"></a>
<p>The following three rules are equivalent:</p>
<pre><code>div.a8 { position: relative; direction: ltr; left: -1em; right: auto }
div.a8 { position: relative; direction: ltr; left: auto; right: 1em }
div.a8 { position: relative; direction: ltr; left: -1em; right: 5em }
</code></pre>
</div>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-top">top</a> and <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a> properties move relatively positioned element(s) up or
down without changing their size. <a class="property" data-link-type="propdesc" href="#propdef-top">Top</a> moves the boxes down, and <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a> moves
them up. Since boxes are not split or stretched as a result of <a class="property" data-link-type="propdesc" href="#propdef-top">top</a> or <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a>,
the used values are always: top = -bottom.</p>
<p>If <a class="property" data-link-type="propdesc" href="#propdef-top">top</a> and <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a> are <span class="css">auto</span>, their used values are both <span class="css">0</span>.</p>
<p>If one of them, <a class="property" data-link-type="propdesc" href="#propdef-top">top</a> or <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a>, is <span class="css">auto</span>, the <span class="css">auto</span> value becomes the
negative of the other.</p>
<p>If neither <a class="property" data-link-type="propdesc" href="#propdef-top">top</a> and <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a> is <span class="css">auto</span>, <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a> is ignored (i.e., the used
value of <a class="property" data-link-type="propdesc" href="#propdef-bottom">bottom</a> will be minus the value of <a class="property" data-link-type="propdesc" href="#propdef-top">top</a>).</p>
<p class="note" role="note">
Note, Although relative positioning could be used as a form of superscripting
and subscripting, the line height is not automatically adjusted to take the