-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.html
1196 lines (977 loc) · 105 KB
/
Overview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang=en><head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Box Alignment Module Level 3</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<style type=text/css>
.issue th:first-child { text-align: left !important; }
[rowspan] > img { float: right; }
[rowspan] { vertical-align: middle; }
small { display: block; }
</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=http://www.w3.org/Icons/w3c_home width=72>
</a>
</p>
<h1 class="p-name no-ref" id=title>CSS Box Alignment Module Level 3</h1>
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20140213>13 February 2014</span></span></span></h2>
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-align/>http://dev.w3.org/csswg/css-align/</a><dt>Latest version:<dd><a href=http://www.w3.org/TR/css3-align/>http://www.w3.org/TR/css3-align/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-align/>http://dev.w3.org/csswg/css-align/</a><dt>Previous Versions:<dd><a href=http://www.w3.org/TR/2012/WD-css3-align-20120612/ rel=previous>http://www.w3.org/TR/2012/WD-css3-align-20120612/</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-align%5D%20feedback">www-style@w3.org</a>
with subject line
“<kbd>[css-align] <var>… message topic …</var></kbd>”(<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)<dt>Test Suite:<dd>None Yet<dt>Editors:
<dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://fantasai.inkedblade.net/contact>fantasai</a><dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://xanthir.com/contact/>Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)<dt>Issue Tracking:<dd><a href=http://www.w3.org/Style/CSS/Tracker/products/39>http://www.w3.org/Style/CSS/Tracker/products/39</a></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> © 2013 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=abstract><span class=content>Abstract</span></h2>
<p class=p-summary data-fill-with=abstract>This module contains the features of <a href=http://www.w3.org/TR/CSS/>CSS</a> relating to the alignment of boxes within their containers in the various CSS box layout models: block layout, table layout, flex layout, and grid layout. (The alignment of text and inline-level content is defined in <a data-biblio-type=informative data-link-type=biblio href=#css3text title=css3text>[CSS3TEXT]</a> and <a data-biblio-type=informative data-link-type=biblio href=#css3line title=css3line>[CSS3LINE]</a>.)
<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>
<h2 class="no-num no-toc no-ref heading settled heading" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-align%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-align” in the subject,
preferably like this:
“[css-align] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=http://www.w3.org/Style/CSS/members>CSS Working Group</a>
(part of the <a href=http://www.w3.org/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.</div>
<div data-fill-with=at-risk></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc><li><a href=#intro><span class=secno>1</span>
Introduction</a><ul class=toc><li><a href=#placement><span class=secno>1.1</span>
Module interactions</a><li><a href=#values><span class=secno>1.2</span>
Values</a></ul><li><a href=#overview><span class=secno>2</span>
Overview of Alignment Properties</a><li><a href=#alignment-values><span class=secno>3</span>
Alignment Values</a><ul class=toc><li><a href=#positional-values><span class=secno>3.1</span>
Positional Alignment: the <span class=css data-link-type=maybe title=center>center</span>, <span class=css data-link-type=maybe title=stretch>stretch</span>, <span class=css data-link-type=maybe title=start>start</span>, <span class=css data-link-type=maybe title=end>end</span>, <span class=css data-link-type=maybe title=self-start>self-start</span>, <span class=css data-link-type=maybe title=self-end>self-end</span>, <span class=css data-link-type=maybe title=flex-start>flex-start</span>, <span class=css data-link-type=maybe title=flex-end>flex-end</span>, <span class=css data-link-type=maybe title=left>left</span>, and <span class=css data-link-type=maybe title=right>right</span> keywords</a><li><a href=#baseline><span class=secno>3.2</span>
Baseline Alignment: the <span class=css data-link-type=maybe title=baseline>baseline</span> keyword</a><ul class=toc><li><a href=#baseline-rules><span class=secno>3.2.1</span>
Determining the Baseline of a Box</a></ul><li><a href=#distribution-values><span class=secno>3.3</span>
Distributed Alignment: the <span class=css data-link-type=maybe title=space-between>space-between</span>, <span class=css data-link-type=maybe title=space-around>space-around</span>, and <span class=css data-link-type=maybe title=space-evenly>space-evenly</span> keywords</a><li><a href=#overflow-values><span class=secno>3.4</span>
Overflow Alignment: the <span class=css data-link-type=maybe title=safe>safe</span> and <span class=css data-link-type=maybe title=true>true</span> keywords</a></ul><li><a href=#content-distribution><span class=secno>4</span>
Content Distribution: the <span class=property data-link-type=propdesc title=justify-content>justify-content</span> and <span class=property data-link-type=propdesc title=align-content>align-content</span> properties</a><ul class=toc><li><a href=#baseline-align-content><span class=secno>4.1</span>
Baseline Content-Alignment</a></ul><li><a href=#self-alignment><span class=secno>5</span>
Self-Alignment: Aligning the Box within its Parent</a><ul class=toc><li><a href=#justify-self-property><span class=secno>5.1</span>
Inline/Main-Axis Alignment: the <span class=property data-link-type=propdesc title=justify-self>justify-self</span> property</a><li><a href=#align-self-property><span class=secno>5.2</span>
Block/Cross-Axis Alignment: the <span class=property data-link-type=propdesc title=align-self>align-self</span> property</a><li><a href=#baseline-align-self><span class=secno>5.3</span>
Baseline Self-Alignment</a></ul><li><a href=#default-alignment><span class=secno>6</span>
Default Alignment</a><ul class=toc><li><a href=#justify-items-property><span class=secno>6.1</span>
Inline/Main-Axis Alignment: the <span class=property data-link-type=propdesc title=justify-items>justify-items</span> property</a><li><a href=#align-items-property><span class=secno>6.2</span>
Block/Cross-Axis Alignment: the <span class=property data-link-type=propdesc title=align-items>align-items</span> property</a></ul><li><a href=#changes><span class=secno>7</span>
Changes</a><li><a href=#acknowledgments><span class=secno></span>
Acknowledgments</a><li><a href=#conformance><span class=secno></span>
Conformance</a><ul class=toc><li><a href=#conventions><span class=secno></span>
Document conventions</a><li><a href=#conformance-classes><span class=secno></span>
Conformance classes</a><li><a href=#partial><span class=secno></span>
Partial implementations</a><li><a href=#experimental><span class=secno></span>
Experimental implementations</a><li><a href=#testing><span class=secno></span>
Non-experimental implementations</a></ul><li><a href=#references><span class=secno></span>
References</a><ul class=toc><li><a href=#normative><span class=secno></span>
Normative References</a><li><a href=#informative><span class=secno></span>
Informative References</a></ul><li><a href=#index><span class=secno></span>
Index</a><li><a href=#property-index><span class=secno></span>
Property index</a><li><a href=#issues-index><span class=secno></span>Issues Index</a></ul></div>
<h2 class="heading settled heading" data-level=1 id=intro><span class=secno>1 </span><span class=content>
Introduction</span><a class=self-link href=#intro></a></h2>
<p> <em>This section is not normative.</em>
<p> CSS Levels 1 and 2 allowed for the alignment of text via <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-text-3/#text-align title=text-align>text-align</a> and
the alignment of blocks by balancing <span class=css data-link-for=margin data-link-type=maybe title=auto>auto</span> margins. However, except in
table cells, vertical alignment was not possible. As CSS3 adds further
capabilities, the ability to align boxes in various dimensions becomes more
critical. This module attempts to create a cohesive and common box alignment
model to share among all of CSS.
<p class=note> Note: The alignment of text and inline-level content is defined in <a data-biblio-type=informative data-link-type=biblio href=#css3text title=css3text>[CSS3TEXT]</a> and <a data-biblio-type=informative data-link-type=biblio href=#css3line title=css3line>[CSS3LINE]</a>.
<p> Inspiration for this document:
<p> <ul>
<li><a href=http://wiki.csswg.org/ideas/centering#alignment-property>summary of a discussion for implementing <CENTER></a>
<li><a href=https://lists.w3.org/Archives/Member/w3c-css-wg/2008AprJun/0015.html>Minutes from March 2008 F2F</a>
<li><a href=http://lists.w3.org/Archives/Public/www-style/2012Feb/0743.html>fantasai’s attempt to merge all alignment properties</a>
</ul>
<h3 class="heading settled heading" 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 adds some new alignment capabilities to the block layout
model described in <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a> chapters 9 and 10 and defines the interaction
of these properties with the alignment of table cell content using
<a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align title=vertical-align>vertical-align</a>, as defined in <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a> chapter 17.
The interaction of these properties with
Grid Layout <a data-biblio-type=normative data-link-type=biblio href=#css3-grid-layout title=css3-grid-layout>[CSS3-GRID-LAYOUT]</a>
and Flexible Box Layout <a data-biblio-type=normative data-link-type=biblio href=#css3-flexbox title=css3-flexbox>[CSS3-FLEXBOX]</a>
is defined in their respective modules.
<p> No properties in this module apply to the <code>::first-line</code> or
<code>::first-letter</code> pseudo-elements.
<h3 class="heading settled heading" data-level=1.2 id=values><span class=secno>1.2 </span><span class=content>
Values</span><a class=self-link href=#values></a></h3>
<p> This specification follows the
<a href=http://www.w3.org/TR/CSS21/about.html#property-defs>CSS property
definition conventions</a> from <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>.
Other CSS modules may expand the definitions of these value types: for
example <a data-biblio-type=informative data-link-type=biblio href=#css3val title=css3val>[CSS3VAL]</a>, when combined with this module, adds the
<span class=css data-link-type=maybe title=initial>initial</span> keyword as a possible property value.
<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.
<h2 class="heading settled heading" data-level=2 id=overview><span class=secno>2 </span><span class=content>
Overview of Alignment Properties</span><a class=self-link href=#overview></a></h2>
<p> The alignment properties in CSS can be described along two axes:
<p> <ul>
<li>which dimension they apply to (inline vs. stacking), and
<li>whether they control the position of the box within its parent, or the box’s content within itself.
</ul>
<p class=note> Note: This proposal uses the terms “justify” and “align” to distinguish
between alignment in the inline and stacking dimensions, respectively.
The choice is somewhat arbitrary, but having the two terms allows for
a consistent naming scheme that works across all of CSS’s layout models.
<p> The following table summarizes the proposed alignment properties
and the display types they can apply to.
<table class=data>
<colgroup span=1></colgroup>
<colgroup span=2></colgroup>
<colgroup span=1></colgroup>
<thead>
<tr>
<th>Common
<th>Axis
<th>Aligns
<th>Applies to
</thead>
<tbody>
<tr>
<th><a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a>
<td>inline
<td rowspan=2>
<img alt="" height=106 src=images/content-example.svg width=106>
content within element
<small>(effectively adjusts padding)</small>
<td>block containers and flex containers
<tr>
<th><a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a>
<td>stacking
<td>block containers and flex containers
<tbody>
<tr>
<th><a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a>
<td>inline
<td rowspan=2>
<img alt="" height=106 src=images/self-example.svg width=106>
element within parent
<small>(effectively adjusts margins)</small>
<td>block-level elements and grid items
<tr>
<th><a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a>
<td>stacking
<td>flex items and grid items
<tbody>
<tr>
<th><a class=property data-link-type=propdesc href=#propdef-justify-items title=justify-items>justify-items</a>
<td>inline
<td rowspan=2>
<img alt="" height=106 src=images/items-example.svg width=106>
items inside element
<small>(controls child items’ <span class=css data-link-type=maybe title="align/justify-self: auto">align/justify-self: auto</span>)</small>
<td>grid containers
<tr>
<th><a class=property data-link-type=propdesc href=#propdef-align-items title=align-items>align-items</a>
<td>stacking
<td>flex containers and grid containers
</table>
<p class=issue id=issue-1ad5b2aa><a class=self-link href=#issue-1ad5b2aa></a>
The exact definition of these properties
outside what’s <a href=http://www.w3.org/TR/css3-flexbox>what’s defined in Flexbox</a>
is still <strong>being worked out</strong>.
This is a <strong>second Working Draft</strong>
and is <strong>NOT STABLE</strong>.
<p class=note> Note: The <a class=property data-link-type=propdesc title=*-items>*-items</a> values don’t affect the element itself.
When set on a flex container or grid container,
they specify the interpretation of any <span class=css data-link-type=maybe title="align/justify-self: auto">align/justify-self: auto</span> used on the items in the container element.
<h2 class="heading settled heading" data-level=3 id=alignment-values><span class=secno>3 </span><span class=content>
Alignment Values</span><a class=self-link href=#alignment-values></a></h2>
<p> All of the alignment properties use a common set of values,
defined below.
<dl>
<dt><dfn data-dfn-type=dfn data-export="" id=alignment-subject>alignment subject<a class=self-link href=#alignment-subject></a></dfn>
<dd>
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the thing or things being aligned by the property.
For <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> and <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a>,
the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the margin box of the box the property is set on.
For <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> and <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a>,
the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is defined by the layout mode.
<dt><dfn data-dfn-type=dfn data-export="" id=alignment-container>alignment container<a class=self-link href=#alignment-container></a></dfn>
<dd>
The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the rectangle that the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is aligned within.
This is defined by the layout mode,
but is usually the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>’s containing block.
</dl>
<h3 class="heading settled heading" data-level=3.1 id=positional-values><span class=secno>3.1 </span><span class=content>
Positional Alignment: the <a class=css data-link-type=maybe href=#valuedef-center title=center>center</a>, <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a>, <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>, <a class=css data-link-type=maybe href=#valuedef-end title=end>end</a>, <a class=css data-link-type=maybe href=#valuedef-self-start title=self-start>self-start</a>, <a class=css data-link-type=maybe href=#valuedef-self-end title=self-end>self-end</a>, <a class=css data-link-type=maybe href=#valuedef-flex-start title=flex-start>flex-start</a>, <a class=css data-link-type=maybe href=#valuedef-flex-end title=flex-end>flex-end</a>, <a class=css data-link-type=maybe href=#valuedef-left title=left>left</a>, and <a class=css data-link-type=maybe href=#valuedef-right title=right>right</a> keywords</span><a class=self-link href=#positional-values></a></h3>
<p> The positional alignment keywords specify a position for an <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>
with respect to its <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>.
<p> The <a class="production css-code" data-link-type=type href=#typedef-item-position title="<item-position>"><item-position></a> set of values is used by <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> and <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a>
to align the box within its <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
and also by <a class=property data-link-type=propdesc href=#propdef-justify-items title=justify-items>justify-items</a> and <a class=property data-link-type=propdesc href=#propdef-align-items title=align-items>align-items</a>
(to specify default values for <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> and <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a>).
The <a class="production css-code" data-link-type=type href=#typedef-content-position title="<content-position>"><content-position></a> set of values is used by <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> and <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a>
to align the box’s contents within itself.
<pre class=prod> <dfn class=css-code data-dfn-type=type data-export="" id=typedef-item-position><item-position><a class=self-link href=#typedef-item-position></a></dfn> = center | start | end | self-start | self-end |
flex-start | flex-end | left | right;
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-content-position><content-position><a class=self-link href=#typedef-content-position></a></dfn> = center | start | end | flex-start | flex-end | left | right;
</pre>
<p> Values have the following meanings:
<dl data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for="<item-position>, <content-position>" data-dfn-type=value data-export="" id=valuedef-center>center<a class=self-link href=#valuedef-center></a></dfn>
<dd>Centers the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> within its <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>.
<dt><dfn class=css-code data-dfn-for="<item-position>, <content-position>" data-dfn-type=value data-export="" id=valuedef-start>start<a class=self-link href=#valuedef-start></a></dfn>
<dd>Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>’s start edge.
<dt><dfn class=css-code data-dfn-for="<item-position>, <content-position>" data-dfn-type=value data-export="" id=valuedef-end>end<a class=self-link href=#valuedef-end></a></dfn>
<dd>Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>’s end edge.
<dt><dfn class=css-code data-dfn-for="<item-position>" data-dfn-type=value data-export="" id=valuedef-self-start>self-start<a class=self-link href=#valuedef-self-start></a></dfn>
<dd>Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the edge of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>
corresponding to the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>’s start side.
If the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#writing-mode0 title="writing modes">writing modes</a> of the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> and the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> are <a data-link-type=dfn title=orthogonal>orthogonal</a>,
this value computes to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<dt><dfn class=css-code data-dfn-for="<item-position>" data-dfn-type=value data-export="" id=valuedef-self-end>self-end<a class=self-link href=#valuedef-self-end></a></dfn>
<dd>Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the edge of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>
corresponding to the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>’s end side.
If the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#writing-mode0 title="writing modes">writing modes</a> of the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> and the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> are <a data-link-type=dfn title=orthogonal>orthogonal</a>,
this value computes to <a class=css data-link-type=maybe href=#valuedef-end title=end>end</a>.
<dt><dfn class=css-code data-dfn-for="<item-position>, <content-position>" data-dfn-type=value data-export="" id=valuedef-flex-start>flex-start<a class=self-link href=#valuedef-flex-start></a></dfn>
<dd><strong>Only used in flex layout.</strong> <a data-biblio-type=normative data-link-type=biblio href=#css3-flexbox title=css3-flexbox>[CSS3-FLEXBOX]</a>
Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the edge of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>
corresponding to the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-container title="flex container">flex container</a>’s main-start or cross-start side, as appropriate.
When used in layout modes other than Flexbox,
this value computes to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<dt><dfn class=css-code data-dfn-for="<item-position>, <content-position>" data-dfn-type=value data-export="" id=valuedef-flex-end>flex-end<a class=self-link href=#valuedef-flex-end></a></dfn>
<dd><strong>Only used in flex layout.</strong>
Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the edge of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>
corresponding to the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-container title="flex container">flex container</a>’s main-end or cross-end side, as appropriate.
When used in layout modes other than Flexbox,
this value computes to <a class=css data-link-type=maybe href=#valuedef-end title=end>end</a>.
<dt><dfn class=css-code data-dfn-for="<item-position>, <content-position>" data-dfn-type=value data-export="" id=valuedef-left>left<a class=self-link href=#valuedef-left></a></dfn>
<dd>Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>’s <a href=http://www.w3.org/TR/css3-writing-modes/#line-left>line-left</a> edge.
If the property’s axis is not parallel with the inline axis,
this value computes to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<dt><dfn class=css-code data-dfn-for="<item-position>, <content-position>" data-dfn-type=value data-export="" id=valuedef-right>right<a class=self-link href=#valuedef-right></a></dfn>
<dd>Aligns the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> to be flush with the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>’s <a href=http://www.w3.org/TR/css3-writing-modes/#line-right>line-right</a> edge.
If the property’s axis is not parallel with the inline axis,
this value computes to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
</dl>
<p class=issue id=issue-511afb430><a class=self-link href=#issue-511afb430></a>
Add example images.
<h3 class="heading settled heading" data-level=3.2 id=baseline><span class=secno>3.2 </span><span class=content>
Baseline Alignment: the <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a> keyword</span><a class=self-link href=#baseline></a></h3>
<p> Baseline alignment is a form of positional alignment
that relies on aligning the baselines of related <a data-link-type=dfn href=#alignment-subject title="alignment subjects">alignment subjects</a>
to each other.
<dl>
<dt><dfn class=css-code data-dfn-for="justify-content, justify-self, justify-items, align-content, align-self, align-items" data-dfn-type=value data-export="" id=valuedef-baseline>baseline<a class=self-link href=#valuedef-baseline></a></dfn>
<dd>
For table cells, grid items, and flex items, aligns the
cell/item’s <a data-link-type=dfn href=http://dev.w3.org/csswg/selectors-3/#first-formatted-line0 title="first formatted line">first formatted line</a>'s baseline, if any,
with the same baseline in other <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a>-aligned cells/items in the row/column (as appropriate for the axis).
<p> In the case of <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a>/<a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a>,
this shifts the content of the box within it,
and may also affect its sizing.
In the case of <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a>/<a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a>
this shifts the entire box within its container,
and may affect the sizing of its container.
<p> If the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>’s position is not fully determined by baseline alignment,
the content is start-aligned insofar as possible while preserving the baseline alignment.
(Content that has no first-line baseline is thus start-aligned.)
</dl>
<p class=issue id=issue-511afb431><a class=self-link href=#issue-511afb431></a>Add example images.
<h4 class="heading settled heading" data-level=3.2.1 id=baseline-rules><span class=secno>3.2.1 </span><span class=content>
Determining the Baseline of a Box</span><a class=self-link href=#baseline-rules></a></h4>
<p> The baseline of a box is determined differently based on the layout model, as follow:
<dl>
<dt><span class=css data-link-type=maybe title=block>block</span>
<dt><span class=css data-link-type=maybe title=list-item>list-item</span>
<dd>
The inline-axis baseline of a block is the baseline of the first in-flow line box in the block,
or the first in-flow block-level child in the block that has a baseline,
whichever comes first.
If there is no such line box or child,
then the block has no baseline.
For the purposes of finding a baseline,
in-flow boxes with a scrolling mechanisms (see the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-overflow-3/#overflow0 title=overflow>overflow</a> property)
must be considered as if scrolled to their origin position.
<p> A block has no block-axis baseline.
<dt><span class=css data-link-type=maybe title=table>table</span>
<dd>
The inline-axis baseline of a table box is the baseline of its first row.
However, when calculating the baseline of an inline-block,
table boxes must be skipped.
<p> The block-axis baseline of a table is undefined.
<p class=issue id=issue-f2630124><a class=self-link href=#issue-f2630124></a>
Or does it have no baseline?
Or is it based on its first column?
<dt><span class=css data-link-type=maybe title=table-row>table-row</span>
<dd>
If any cells in the row participate in its baseline alignment,
the inline-axis baseline of the row is their baseline,
after baseline alignment has been performed.
Otherwise, the inline-axis baseline of the row is the bottom content edge of the lowest cell in the row.
<a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>
<p> A table row has no block-axis baseline.
<dt><span class=css data-link-type=maybe title=table-cell>table-cell</span>
<dd>
The inline-axis baseline of a table cell is the baseline of the first in-flow line box in the cell,
or the first in-flow element that contributes a baseline in that axis,
whichever comes first.
<p> A table cell has no block-axis baseline.
<dt><span class=css data-link-type=maybe title=flex>flex</span>
<dd>
See <a href=http://www.w3.org/TR/css3-flexbox/#flex-baselines>Flex Baselines</a> in <a data-biblio-type=normative data-link-type=biblio href=#css3-flexbox title=css3-flexbox>[CSS3-FLEXBOX]</a>.
<dt><a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-grid-1/#grid title=grid>grid</a>
<dd>
See <a href=http://www.w3.org/TR/css3-grid-layout/#grid-baselines>Grid Baselines</a> in <a data-biblio-type=normative data-link-type=biblio href=#css3-grid-layout title=css3-grid-layout>[CSS3-GRID-LAYOUT]</a>.
</dl>
<p class=issue id=issue-c300815d><a class=self-link href=#issue-c300815d></a>
Maybe these things are wrong?
CSS 2.1 is really weird about baseline alignment.
This whole section needs to be better defined and reviewed.
<h3 class="heading settled heading" data-level=3.3 id=distribution-values><span class=secno>3.3 </span><span class=content>
Distributed Alignment: the <a class=css data-link-type=maybe href=#valuedef-space-between title=space-between>space-between</a>, <a class=css data-link-type=maybe href=#valuedef-space-around title=space-around>space-around</a>, and <a class=css data-link-type=maybe href=#valuedef-space-evenly title=space-evenly>space-evenly</a> keywords</span><a class=self-link href=#distribution-values></a></h3>
<p> The distribution values are used by <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> and <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a>
to distribute the items in the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>
evenly between the start and end edges of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>.
When the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> cannot be distributed in this way,
they behave as their <dfn data-dfn-type=dfn data-export="" id=fallback-alignment>fallback alignment<a class=self-link href=#fallback-alignment></a></dfn>.
Each distribution value has an associated <a class="production css-code" data-link-type=type href=#typedef-content-position title="<content-position>"><content-position></a> as a <a data-link-type=dfn href=#fallback-alignment title="fallback alignment">fallback alignment</a>,
but one can alternatively be explicitly specified in the property.
<pre class=prod> <dfn class=css-code data-dfn-type=type data-export="" id=typedef-content-distribution><content-distribution><a class=self-link href=#typedef-content-distribution></a></dfn> = space-between | space-around | space-evenly | stretch</pre>
<dl data-dfn-for="<content-distribution>" data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for="<content-distribution>" data-dfn-type=value data-export="" id=valuedef-space-between>space-between<a class=self-link href=#valuedef-space-between></a></dfn>
<dd>
The items are evenly distributed in the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>.
The first item is placed flush with the start edge of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
the last item is placed flush with the end edge of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
and the remaining items are distributed so that the spacing between any two adjacent items is the same.
Unless otherwise specified,
this value falls back to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<dt><dfn class=css-code data-dfn-for="<content-distribution>" data-dfn-type=value data-export="" id=valuedef-space-around>space-around<a class=self-link href=#valuedef-space-around></a></dfn>
<dd>
The items are evenly distributed in the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
with a half-size space on either end.
The items are distributed so that the spacing between any two adjacent items is the same,
and the spacing before the first and after the last item is half the size of the other spacing.
Unless otherwise specified,
this value falls back to <a class=css data-link-type=maybe href=#valuedef-center title=center>center</a>.
<dt><dfn class=css-code data-dfn-for="<content-distribution>" data-dfn-type=value data-export="" id=valuedef-space-evenly>space-evenly<a class=self-link href=#valuedef-space-evenly></a></dfn>
<dd>
The items are evenly distributed in the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
with a full-size space on either end.
The items are distributed so that the spacing between any two adjacent items,
before the first item,
and after the last item
is the same.
Unless otherwise specified,
this value falls back to <a class=css data-link-type=maybe href=#valuedef-center title=center>center</a>.
<dt><dfn class=css-code data-dfn-for="<content-distribution>" data-dfn-type=value data-export="" id=valuedef-stretch>stretch<a class=self-link href=#valuedef-stretch></a></dfn>
<dd>
If the combined size of the items is less than the size of the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
any <span class=css data-link-for=width data-link-type=maybe title=auto>auto</span>-sized items have their size increased equally so that the combined size exactly fills the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>.
Otherwise,
or if there are no <span class=css data-link-for=width data-link-type=maybe title=auto>auto</span>-sized items,
this value is identical to <a class=css data-link-type=maybe href=#valuedef-flex-start title=flex-start>flex-start</a>.
<span class=note>(For layout modes other than flex layout, <a class=css data-link-type=maybe href=#valuedef-flex-start title=flex-start>flex-start</a> is identical to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.)</span>
</dl>
<p class=issue id=issue-511afb43><a class=self-link href=#issue-511afb43></a>
Add example images.
<h3 class="heading settled heading" data-level=3.4 id=overflow-values><span class=secno>3.4 </span><span class=content>
Overflow Alignment: the <a class=css data-link-type=maybe href=#valuedef-safe title=safe>safe</a> and <a class=css data-link-type=maybe href=#valuedef-true title=true>true</a> keywords</span><a class=self-link href=#overflow-values></a></h3>
<p> When the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is larger than the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
it will overflow.
Some alignment modes, if honored in this situation,
may cause data loss:
for example, if the contents of a sidebar are centered,
when they overflow they may send part of their boxes past the viewport’s start edge,
which can’t be scrolled to.
<p> To help combat this problem,
an <dfn data-dfn-type=dfn data-export="" id=overflow-alignment>overflow alignment<a class=self-link href=#overflow-alignment></a></dfn> mode can be explicitly specified.
"True" alignment honors the specified alignment mode in overflow situations, even if it causes data loss,
while "safe" alignment changes the alignment mode in overflow situations in an attempt to avoid data loss.
<p> If the <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> isn’t explicitly specified,
the default <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> is determined by the layout mode.
Document-centric layout modes, such as block layout, default to "safe" <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a>,
while design-centric layout modes, such as flex layout, default to "true" <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a>.
<pre class=prod><dfn class=css-code data-dfn-type=type data-export="" id=typedef-overflow-position><overflow-position><a class=self-link href=#typedef-overflow-position></a></dfn> = true | safe</pre>
<dl data-dfn-for="<overflow-position>" data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for="<overflow-position>" data-dfn-type=value data-export="" id=valuedef-safe>safe<a class=self-link href=#valuedef-safe></a></dfn>
<dd>
If the size of the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> overflows the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is instead aligned as if the alignment mode were <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<dt><dfn class=css-code data-dfn-for="<overflow-position>" data-dfn-type=value data-export="" id=valuedef-true>true<a class=self-link href=#valuedef-true></a></dfn>
<dd>
Regardless of the relative sizes of the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> and <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>,
the given alignment value is honored.
</dl>
<p class=issue id=issue-8fcc582f><a class=self-link href=#issue-8fcc582f></a>
Transplant example 10 from flexbox.
<h2 class="heading settled heading" data-level=4 id=content-distribution><span class=secno>4 </span><span class=content>
Content Distribution: the <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> and <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> properties</span><a class=self-link href=#content-distribution></a></h2>
<p> The <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> and <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> properties control alignment of the box’s content within the box.
<div class=figure>
<img alt="Diagram showing that the alignment of the content within the element is affected." height=212 src=images/content-example.svg width=212>
</div>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-justify-content>justify-content<a class=self-link href=#propdef-justify-content></a></dfn>, <dfn class=css-code data-dfn-type=property data-export="" id=propdef-align-content>align-content<a class=self-link href=#propdef-align-content></a></dfn><tr><th>Value:<td class=prod>auto | <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a> | [ <a class="production css-code" data-link-type=type href=#typedef-item-position title="<item-position>"><item-position></a> <a class="production css-code" data-link-type=type href=#typedef-content-position title="<content-position>"><content-position></a>? | <a class="production css-code" data-link-type=type href=#typedef-content-position title="<content-position>"><content-position></a> ] && <a class="production css-code" data-link-type=type href=#typedef-overflow-position title="<overflow-position>"><overflow-position></a>?<tr><th>Initial:<td>auto<tr><th>Applies to:<td>block containers, flex containers, and grid containers<tr><th>Inherited:<td>no<tr><th>Media:<td>visual<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>n/a<tr><th>Animatable:<td>no</table>
<p> Aligns the contents of the box as a whole along the box’s inline/row/main axis.
Values other than <dfn class=css-code data-dfn-for="justify-content, align-content" data-dfn-type=value data-export="" id=valuedef-auto0>auto<a class=self-link href=#valuedef-auto0></a></dfn> are <a href=#alignment-values>defined above</a>.
If both a <a class="production css-code" data-link-type=type href=#typedef-item-position title="<item-position>"><item-position></a> and <a class="production css-code" data-link-type=type href=#typedef-content-position title="<content-position>"><content-position></a> are given,
the second value represents an explicit <a data-link-type=dfn href=#fallback-alignment title="fallback alignment">fallback alignment</a>.
<dl>
<dt>Block Containers:
<dd>
The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the <a data-link-type=dfn title="block container">block container</a>’s content box.
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the entire contents of the block.
<p> The <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> property applies along the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#block-axis- title="block axis">block axis</a>,
but if a <var><content-distribution></var> is specified
the <a data-link-type=dfn href=#fallback-alignment title="fallback alignment">fallback alignment</a> is used instead.
The <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> property does not apply to and has no effect on block containers.
<p> All values other than <span class=css data-link-for=justify-content data-link-type=maybe title=auto>auto</span> force the block container to establish a new formatting context.
For table cells, the behavior of the <span class=css data-link-for=justify-content data-link-type=maybe title=auto>auto</span> depends on the computed value of <a class=property data-link-type=propdesc href=http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align title=vertical-align>vertical-align</a>:
<a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-writing-modes-3/#top title=top>top</a> makes it behave as <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>,
<span class=css data-link-type=maybe title=middle>middle</span> makes it behave as <a class=css data-link-type=maybe href=#valuedef-center title=center>center</a>,
<a class=css data-link-type=maybe href=http://dev.w3.org/csswg/css-writing-modes-3/#bottom title=bottom>bottom</a> makes it behave as <a class=css data-link-type=maybe href=#valuedef-end title=end>end</a>,
and all other values make it behave as <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a>.
<span class=css data-link-for=justify-content data-link-type=maybe title=auto>auto</span> otherwise behaves as <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<dt>Multicol Layout:
<dd>
The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-multicol-1/#multi-column-element title="multi-column element">multi-column element</a>’s content box.
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the column boxes, as a unit.
<p> The <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> property applies along the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#block-axis- title="block axis">block axis</a>,
but if a <var><content-distribution></var> is specified
the <a data-link-type=dfn href=#fallback-alignment title="fallback alignment">fallback alignment</a> is used instead.
The <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> property does not apply to and has no effect on multi-column elements.
<p> <span class=css data-link-for=justify-content data-link-type=maybe title=auto>auto</span> behaves as <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<dt>Flex Containers:
<dd>
<span class=css data-link-for=justify-content data-link-type=maybe title=auto>auto</span> computes to <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a>.
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-container title="flex container">flex container</a>’s content box.
For <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a>, the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-item title="flex items">flex items</a> in each <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-line title="flex line">flex line</a>;
for <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a>, the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-line title="flex lines">flex lines</a>.
<p> The <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> property applies along the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#cross-axis title="cross axis">cross axis</a>.
The <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> property applies along the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#main-axis title="main axis">main axis</a>,
but <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> behaves as <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<p> See <a data-biblio-type=normative data-link-type=biblio href=#css3-flexbox title=css3-flexbox>[CSS3-FLEXBOX]</a> for details.
<dt>Grid Containers:
<dd>
<span class=css data-link-for=justify-content data-link-type=maybe title=auto>auto</span> computes to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>, and <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> behaves like <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid-container title="grid container">grid container</a>’s content box.
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the bounds of the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid title=grid>grid</a>.
<span class=issue id=issue-dda0e769><a class=self-link href=#issue-dda0e769></a>Need to dfn a better term for this in Grid.</span>
<p> The <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> property applies along the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#block-axis- title="block axis">block (column) axis</a>.
The <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> property applies along the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline (row) axis</a>.
In both properties, if a <var><content-distribution></var> is specified,
the <a data-link-type=dfn href=#fallback-alignment title="fallback alignment">fallback alignment</a> is used instead.
</dl>
<h3 class="heading settled heading" data-level=4.1 id=baseline-align-content><span class=secno>4.1 </span><span class=content>
Baseline Content-Alignment</span><a class=self-link href=#baseline-align-content></a></h3>
<p> The content of boxes participating in row-like layout contexts can be baseline-aligned to each other.
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> of a box participating in <a data-link-type=dfn href=#baseline-content-alignment title="baseline content-alignment">baseline content-alignment</a>
is shifted such that the baseline of the <a data-link-type=dfn href=http://dev.w3.org/csswg/selectors-3/#first-formatted-line0 title="first formatted line">first formatted line</a> of all participating boxes align,
and the intrinsic size of each box is increased
by the distance the content needed to shift
in order to thus align the baselines.
<p> The set of boxes that participate in <dfn data-dfn-type=dfn data-export="" id=baseline-content-alignment>baseline content-alignment<a class=self-link href=#baseline-content-alignment></a></dfn> together depends on the layout model:
<dl>
<dt>Table Cells:
<dd>
A <a data-link-type=dfn title="table cell">table cell</a> participates in <a data-link-type=dfn href=#baseline-content-alignment title="baseline content-alignment">baseline content-alignment</a>
in either its row or column (whichever matches its <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a>)
if its computed <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> is <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a>.
<dt>Flex Items:
<dd>
A <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-item title="flex item">flex item</a> participates in <a data-link-type=dfn href=#baseline-content-alignment title="baseline content-alignment">baseline content-alignment</a>
in its flex line if
its computed <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> is <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a>,
its computed <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> is <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> or <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>,
and its <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a> is parallel to the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#main-axis title="main axis">main axis</a>.
<dt>Grid Items:
<dd>
A <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid-item title="grid item">grid item</a> participates in <a data-link-type=dfn href=#baseline-content-alignment title="baseline content-alignment">baseline content-alignment</a>
in either its row or column (whichever matches its <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a>)
if its computed <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a> is <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a>,
and its computed <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> or <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> (whichever affects its <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#block-axis- title="block axis">block axis</a>) is <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> or <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a>.
</dl>
<p> If a cell/item spans multiple rows or columns,
it participates in alignment within its start-most row/column only.
<h2 class="heading settled heading" data-level=5 id=self-alignment><span class=secno>5 </span><span class=content>
Self-Alignment: Aligning the Box within its Parent</span><a class=self-link href=#self-alignment></a></h2>
<p> The <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> and <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> properties control alignment of the box within its containing block.
<div class=figure>
<img alt="Diagram showing that the alignment of the element within its containing block is affected." height=212 src=images/self-example.svg width=212>
</div>
<h3 class="heading settled heading" data-level=5.1 id=justify-self-property><span class=secno>5.1 </span><span class=content>
Inline/Main-Axis Alignment: the <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> property</span><a class=self-link href=#justify-self-property></a></h3>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-justify-self>justify-self<a class=self-link href=#propdef-justify-self></a></dfn><tr><th>Value:<td class=prod>auto | <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> | <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a> | [ <a class="production css-code" data-link-type=type href=#typedef-item-position title="<item-position>"><item-position></a> && <a class="production css-code" data-link-type=type href=#typedef-overflow-position title="<overflow-position>"><overflow-position></a>? ]<tr><th>Initial:<td>auto<tr><th>Applies to:<td>block-level boxes, absolutely-positioned boxes, and grid items<tr><th>Inherited:<td>no<tr><th>Media:<td>visual<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>n/a<tr><th>Animatable:<td>no</table>
<p> Justifies the box within its parent along the inline/row/main axis:
the box’s outer edges are aligned within its <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>
<a href=#alignment-values>as described by its alignment value</a>.
<p> The <dfn class=css-code data-dfn-for=justify-self data-dfn-type=value data-export="" id=valuedef-auto1>auto<a class=self-link href=#valuedef-auto1></a></dfn> keyword computes to
<a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> on absolutely-positioned elements,
and to the computed value of <a class=property data-link-type=propdesc href=#propdef-justify-items title=justify-items>justify-items</a> on the parent
(minus any <a class=css data-link-type=maybe href=#valuedef-legacy title=legacy>legacy</a> keywords) on all other boxes.
<dl>
<dt>Block-level Boxes:
<dd>
The <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> property applies along its containing block’s <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a>.
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the block’s containing block
except that for block-level elements that establish a block formatting context
and are placed next to a float,
the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is reduced by the space taken up by the float.
(Note: This is the legacy behavior of HTML <code>align</code>.)
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the block’s margin box.
<p> The default <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> is <a class=css data-link-type=maybe href=#valuedef-safe title=safe>safe</a>.
In terms of CSS2.1 block-level formatting <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>,
the rules for "over-constrained" computations in <a href=http://www.w3.org/TR/CSS21/visudet.html#blockwidth>section 10.3.3</a>
are ignored in favor of alignment as specified here
and the used value of the offset properties are not adjusted to correct for the over-constraint.
<p> The <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> value is equivalent to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a> on block-level boxes.
<p> This property does not apply to floats.
<dt>Absolutely-positioned Boxes:
<dd>
The <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> property applies along its containing block’s <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a>.
<p> When neither margin in this dimension is <span class=css data-link-for=margin data-link-type=maybe title=auto>auto</span>
and neither offset property in this dimension is <span class=css data-link-for=top data-link-type=maybe title=auto>auto</span>,
values other than <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> cause <a href=http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width>non-replaced absolutely-positioned boxes</a>
to use shrink-to-fit sizing for calculating <span class=css data-link-for=width data-link-type=maybe title=auto>auto</span> measures,
and <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> dictates alignment as follows:
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the box’s containing block
as modified by the offset properties (<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#top title=top>top</a>/<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#right title=right>right</a>/<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#bottom title=bottom>bottom</a>/<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#left title=left>left</a>).
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the box’s margin box.
<p> The default <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> is <a class=css data-link-type=maybe href=#valuedef-safe title=safe>safe</a>.
In terms of CSS2.1 formatting <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>,
the rules for "over-constrained" computations in <a href=http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width>section 10.3.7</a>
are ignored in favor of alignment as specified here
and the used value of the offset properties are not adjusted to correct for the over-constraint.
<p> The <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> keyword is equivalent to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a> on replaced absolutely-positioned boxes.
(This is because CSS 2.1 does not stretch replaced elements to fit into fixed offsets.)
<dt>Table Cells:
<dd>
This property does not apply to table cells,
because their position and size is fully constrained by table layout.
<dt>Flex Items:
<dd>
This property does not apply to <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-item title="flex items">flex items</a>,
because there is more than one item in the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#main-axis title="main axis">main axis</a>.
See <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-flexbox-1/#propdef-flex title=flex>flex</a> for stretching and <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> for <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#main-axis title=main-axis>main-axis</a> alignment. <a data-biblio-type=normative data-link-type=biblio href=#css3-flexbox title=css3-flexbox>[CSS3-FLEXBOX]</a>
<dt>Grid Items:
<dd>
The <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> property applies along the grid’s <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#row-axis title="row axis">row axis</a>.
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid-cell title="grid cell">grid cell</a>.
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid-item title="grid item">grid item</a>’s margin box.
The default <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> is <a class=css data-link-type=maybe href=#valuedef-true title=true>true</a>.
</dl>
<p class=issue id=issue-8b506393><a class=self-link href=#issue-8b506393></a>
Should we make <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> actually work on block-level/abspos replaced boxes?
To maintain legacy compat, this requires adding a new value (named <span class=css data-link-type=maybe title=normal>normal</span>?)
which has the current behavior of stretching non-replaced boxes and start-aligning replaced ones.
<div class=example>
The effect of these rules is that an auto-sized block-level table,
for example, can be aligned while still having side margins.
If the table’s max-content size is narrower than its containing block,
then it is shrink-wrapped to that size and aligned as specified.
If the table’s max-content size is wider, then it fills its containing block,
and the margins provide appropriate spacing from the containing block edges.
</div>
<h3 class="heading settled heading" data-level=5.2 id=align-self-property><span class=secno>5.2 </span><span class=content>
Block/Cross-Axis Alignment: the <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> property</span><a class=self-link href=#align-self-property></a></h3>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-align-self>align-self<a class=self-link href=#propdef-align-self></a></dfn><tr><th>Value:<td class=prod>auto | <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> | <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a> | [ <a class="production css-code" data-link-type=type href=#typedef-item-position title="<item-position>"><item-position></a> && <a class="production css-code" data-link-type=type href=#typedef-overflow-position title="<overflow-position>"><overflow-position></a>? ]<tr><th>Initial:<td>auto<tr><th>Applies to:<td>block-level boxes<tr><th>Inherited:<td>no<tr><th>Media:<td>visual<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>n/a<tr><th>Animatable:<td>no</table>
<p> Aligns the box within its parent along the block/column/cross axis:
the box’s outer edges are aligned within its <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>
<a href=#alignment-values>as described by its alignment value</a>.
<p> The <dfn class=css-code data-dfn-for=align-self data-dfn-type=value data-export="" id=valuedef-auto2>auto<a class=self-link href=#valuedef-auto2></a></dfn> keyword computes to
<a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> on absolutely-positioned elements,
and to the computed value of <a class=property data-link-type=propdesc href=#propdef-align-items title=align-items>align-items</a> on the parent
(minus any <a class=css data-link-type=maybe href=#valuedef-legacy title=legacy>legacy</a> keywords) on all other boxes.
<dl>
<dt>Block-level Boxes:
<dd>
The <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> property does not apply to block-level boxes
(including floats),
because there is more than one item in the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#block-axis- title="block axis">block axis</a>.
<dt>Absolutely-positioned Boxes:
<dd>
The <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> property applies along its containing block’s <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a>.
<p> When neither margin in this dimension is <span class=css data-link-for=margin data-link-type=maybe title=auto>auto</span>
and neither offset property in this dimension is <span class=css data-link-for=top data-link-type=maybe title=auto>auto</span>,
values other than <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> cause <a href=http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height>non-replaced absolutely-positioned boxes</a>
to use shrink-to-fit sizing for calculating <span class=css data-link-for=width data-link-type=maybe title=auto>auto</span> measures,
and <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> dictates alignment as follows:
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the box’s containing block
as modified by the offset properties (<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#top title=top>top</a>/<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#right title=right>right</a>/<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#bottom title=bottom>bottom</a>/<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-position-3/#left title=left>left</a>).
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the box’s margin box.
<p> The default <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> is <a class=css data-link-type=maybe href=#valuedef-safe title=safe>safe</a>.
In terms of CSS2.1 formatting <a data-biblio-type=normative data-link-type=biblio href=#css21 title=css21>[CSS21]</a>,
the rules for "over-constrained" computations in <a href=http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height>section 10.6.4</a>
are ignored in favor of alignment as specified here
and the used value of the offset properties are not adjusted to correct for the over-constraint.
<p> The <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> keyword is equivalent to <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a> on replaced absolutely-positioned boxes.
(This is because CSS 2.1 does not stretch replaced elements to fit into fixed offsets.)
<dt>Table Cells:
<dd>
This property does not apply to table cells,
because their position and size is fully constrained by table layout.
<dt>Flex Items:
<dd>
The <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> property applies along the flexbox’s <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#cross-axis title="cross axis">cross axis</a>.
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-line title="flex line">flex line</a> the item is in.
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-item title="flex item">flex item</a>’s margin box.
The default <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> is <a class=css data-link-type=maybe href=#valuedef-true title=true>true</a>.
See <a data-biblio-type=normative data-link-type=biblio href=#css3-flexbox title=css3-flexbox>[CSS3-FLEXBOX]</a> for details.
<dt>Grid Items:
<dd>
The <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> property applies along the grid’s <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#column-axis title="column axis">column axis</a>.
<p> The <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid-cell title="grid cell">grid cell</a>.
The <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> is the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid-item title="grid item">grid item</a>’s margin box.
The default <a data-link-type=dfn href=#overflow-alignment title="overflow alignment">overflow alignment</a> is <a class=css data-link-type=maybe href=#valuedef-true title=true>true</a>.
</dl>
<h3 class="heading settled heading" data-level=5.3 id=baseline-align-self><span class=secno>5.3 </span><span class=content>
Baseline Self-Alignment</span><a class=self-link href=#baseline-align-self></a></h3>
<p> Boxes participating in row-like layout contexts can be baseline-aligned to each other.
An <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a> participating in <a data-link-type=dfn href=#baseline-content-alignment title="baseline content-alignment">baseline content-alignment</a>
is shifted such that the baseline of the <a data-link-type=dfn href=http://dev.w3.org/csswg/selectors-3/#first-formatted-line0 title="first formatted line">first formatted line</a> of all participating boxes align,
and the intrinsic size of its <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> is increased
by the largest distance a box needed to shift
in order to thus align the baselines.
<p> The set of boxes that participate in <dfn data-dfn-type=dfn data-noexport="" id=baseline-self-alignment>baseline self-alignment<a class=self-link href=#baseline-self-alignment></a></dfn> together depends on the layout model:
<dl>
<dt>Flex Items:
<dd>
A <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#flex-item title="flex item">flex item</a> participates in <a data-link-type=dfn href=#baseline-content-alignment title="baseline content-alignment">baseline content-alignment</a>
if its <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a> is parallel to the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-flexbox-1/#main-axis title="main axis">main axis</a>.
See <a data-biblio-type=normative data-link-type=biblio href=#css3-flexbox title=css3-flexbox>[CSS3-FLEXBOX]</a> for details.
<dt>Grid Items:
<dd>
A <a data-link-type=dfn href=http://dev.w3.org/csswg/css-grid-1/#grid-item title="grid item">grid item</a> participates in <a data-link-type=dfn href=#baseline-content-alignment title="baseline content-alignment">baseline content-alignment</a>
in either its row or column (whichever matches its <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a>)
if its <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> or <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> property (whichever matches its <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#inline-axis- title="inline axis">inline axis</a>)
computes to <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a>.
</dl>
<p> If a cell/item spans multiple rows or columns,
it participates in alignment within its start-most row/column only.
<h2 class="heading settled heading" data-level=6 id=default-alignment><span class=secno>6 </span><span class=content>
Default Alignment</span><a class=self-link href=#default-alignment></a></h2>
<p> The <a class=property data-link-type=propdesc href=#propdef-align-items title=align-items>align-items</a> and <a class=property data-link-type=propdesc href=#propdef-justify-items title=justify-items>justify-items</a> properties set the default <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> and <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> behavior of the items contained by the element.
<div class=figure>
<img alt="Diagram showing that the alignment of grid items within the element is affected." height=212 src=images/items-example.svg width=212>
</div>
<h3 class="heading settled heading" data-level=6.1 id=justify-items-property><span class=secno>6.1 </span><span class=content>
Inline/Main-Axis Alignment: the <a class=property data-link-type=propdesc href=#propdef-justify-items title=justify-items>justify-items</a> property</span><a class=self-link href=#justify-items-property></a></h3>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-justify-items>justify-items<a class=self-link href=#propdef-justify-items></a></dfn><tr><th>Value:<td class=prod>auto | <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> | <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a> | [ <a class="production css-code" data-link-type=type href=#typedef-item-position title="<item-position>"><item-position></a> && <a class="production css-code" data-link-type=type href=#typedef-overflow-position title="<overflow-position>"><overflow-position></a>? ] | [ legacy && [ <a class=css data-link-type=maybe href=#valuedef-left title=left>left</a> | <a class=css data-link-type=maybe href=#valuedef-right title=right>right</a> | <a class=css data-link-type=maybe href=#valuedef-center title=center>center</a> ] ]<tr><th>Initial:<td>auto<tr><th>Applies to:<td>block containers, flex containers, and grid containers<tr><th>Inherited:<td>no<tr><th>Media:<td>visual<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>n/a<tr><th>Animatable:<td>no</table>
<p> This property specifies the default <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a> for all of the boxes
(including anonymous boxes)
participating in this box’s formatting context.
Values have the following meanings:
<dl data-dfn-for=justify-items data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=justify-items data-dfn-type=value data-export="" id=valuedef-auto3>auto<a class=self-link href=#valuedef-auto3></a></dfn>
<dd>
If the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-cascade-3/#inherited-value title="inherited value">inherited value</a> of <span class=css data-link-type=maybe title=justify-items>justify-items</span> includes the <a class=css data-link-type=maybe href=#valuedef-legacy title=legacy>legacy</a> keyword,
<a class=css data-link-for=justify-items data-link-type=maybe href=#valuedef-auto3 title=auto>auto</a> computes to the the <a data-link-type=dfn href=http://dev.w3.org/csswg/css-cascade-3/#inherited-value title="inherited value">inherited value</a>.
<p> Otherwise, <a class=css data-link-for=justify-items data-link-type=maybe href=#valuedef-auto3 title=auto>auto</a> computes to:
<p> <ul>
<li><a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> for flex containers and grid containers
<li><a class=css data-link-type=maybe href=#valuedef-start title=start>start</a> for everything else
</ul>
<dt><dfn class=css-code data-dfn-for=justify-items data-dfn-type=value data-export="" id=valuedef-legacy>legacy<a class=self-link href=#valuedef-legacy></a></dfn>
<dd>
This keyword causes the value to effectively inherit into descendants.
It can only be combined with the <a class=css data-link-type=maybe href=#valuedef-center title=center>center</a>, <a class=css data-link-type=maybe href=#valuedef-left title=left>left</a>, and <a class=css data-link-type=maybe href=#valuedef-right title=right>right</a> positions.
The alignment keyword, but not the <a class=css data-link-type=maybe href=#valuedef-legacy title=legacy>legacy</a> keyword, is passed to <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a>.
It exists to implement the legacy alignment behavior of HTML’s <code><center></code> element and <code>align</code> attribute.
</dl>
<p> Other values have no special handling and are merely passed to <a class=property data-link-type=propdesc href=#propdef-justify-self title=justify-self>justify-self</a>.
<h3 class="heading settled heading" data-level=6.2 id=align-items-property><span class=secno>6.2 </span><span class=content>
Block/Cross-Axis Alignment: the <a class=property data-link-type=propdesc href=#propdef-align-items title=align-items>align-items</a> property</span><a class=self-link href=#align-items-property></a></h3>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-align-items>align-items<a class=self-link href=#propdef-align-items></a></dfn><tr><th>Value:<td class=prod>auto | <a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> | <a class=css data-link-type=maybe href=#valuedef-baseline title=baseline>baseline</a> | [ <a class="production css-code" data-link-type=type href=#typedef-item-position title="<item-position>"><item-position></a> && <a class="production css-code" data-link-type=type href=#typedef-overflow-position title="<overflow-position>"><overflow-position></a>? ]<tr><th>Initial:<td>auto<tr><th>Applies to:<td>block-level elements<tr><th>Inherited:<td>no<tr><th>Media:<td>visual<tr><th>Computed value:<td>specified value<tr><th>Percentages:<td>n/a<tr><th>Animatable:<td>no</table>
<p> This property specifies the default <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a> for all of the boxes
(including anonymous boxes)
participating in this box’s formatting context.
Values have the following meanings:
<dl data-dfn-for=align-items data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=align-items data-dfn-type=value data-export="" id=valuedef-auto>auto<a class=self-link href=#valuedef-auto></a></dfn>
<dd>
Computes to:
<p> <ul>
<li><a class=css data-link-type=maybe href=#valuedef-stretch title=stretch>stretch</a> for flex containers and grid containers
<li><a class=css data-link-type=maybe href=#valuedef-start title=start>start</a> for everything else
</ul>
</dl>
<p> Other values have no special handling and are merely passed to <a class=property data-link-type=propdesc href=#propdef-align-self title=align-self>align-self</a>.
<h2 class="heading settled heading" data-level=7 id=changes><span class=secno>7 </span><span class=content>
Changes</span><a class=self-link href=#changes></a></h2>
<p> Changes since the <a href=http://www.w3.org/TR/2012/WD-css3-align-20120612/>First Public Working Draft</a> include:
<p> <ul>
<li>
Defined terms <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a> and <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>
to make it easier to define alignment.
<li>
Pulled out all value definitions into a general section on <a href=#alignment-values>Alignment Values</a>.
<li>
Added both <a class=css data-link-type=maybe href=#valuedef-safe title=safe>safe</a> and <a class=css data-link-type=maybe href=#valuedef-true title=true>true</a> as <a href=#overflow-values>overflow alignment keywords</a>
and made the default layout-mode-dependent.
<li>
Removed <span class=css data-link-type=maybe title=head>head</span> and <span class=css data-link-type=maybe title=foot>foot</span> keywords,
defined <a class=css data-link-type=maybe href=#valuedef-start title=start>start</a> and <a class=css data-link-type=maybe href=#valuedef-end title=end>end</a> keywords as relative to the <a data-link-type=dfn href=#alignment-container title="alignment container">alignment container</a>’s <a data-link-type=dfn href=http://dev.w3.org/csswg/css-writing-modes-3/#writing-mode0 title="writing mode">writing mode</a>,
and added <a class=css data-link-type=maybe href=#valuedef-self-start title=self-start>self-start</a> and <a class=css data-link-type=maybe href=#valuedef-self-end title=self-end>self-end</a> to be relative to the <a data-link-type=dfn href=#alignment-subject title="alignment subject">alignment subject</a>.
<li>
Filled out details on <a href=#baseline>baseline alignment</a>.
<li>
Made <a class=property data-link-type=propdesc href=#propdef-justify-items title=justify-items>justify-items</a> handle the <code><CENTER>></code>/<code>align</code> attribute requirements
by adding <a class=css data-link-type=maybe href=#valuedef-legacy title=legacy>legacy</a> keyword.
<li>
Added <a data-link-type=dfn href=#fallback-alignment title="fallback alignment">fallback alignment</a> ability for <a class=property data-link-type=propdesc href=#propdef-justify-content title=justify-content>justify-content</a> and <a class=property data-link-type=propdesc href=#propdef-align-content title=align-content>align-content</a>.
<li>
Defined alignment behavior of absolutely-positioned elements.
<li>
Improved details on alignment behavior of other layout modes.
</ul>
<h2 class="no-num heading settled heading" id=acknowledgments><span class=content>
Acknowledgments</span><a class=self-link href=#acknowledgments></a></h2>
<p> Special thanks goes to Markus Mielke, Alex Mogilevsky, and the
participants in the CSSWG’s March 2008 F2F alignment discussions.
<h2 class="no-ref no-num heading settled heading" id=conformance><span class=content>
Conformance</span><a class=self-link href=#conformance></a></h2>
<h3 class="no-ref heading settled heading" id=conventions><span class=content>
Document conventions</span><a class=self-link href=#conventions></a></h3>
<p>Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words "MUST",
"MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT",
"RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
<p>All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. <a data-biblio-type=normative data-link-type=biblio href=#rfc2119 title=rfc2119>[RFC2119]</a></p>
<p>Examples in this specification are introduced with the words "for example"
or are set apart from the normative text with <code>class="example"</code>,
like this:
<div class=example>
<p>This is an example of an informative example.</p>
</div>