-
Notifications
You must be signed in to change notification settings - Fork 792
Expand file tree
/
Copy pathOverview.html
More file actions
1419 lines (1412 loc) · 145 KB
/
Overview.html
File metadata and controls
1419 lines (1412 loc) · 145 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html><html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>CSS Box Alignment Module Level 3</title>
<meta content="revising" name="csswg-work-status">
<meta content="ED" name="w3c-status">
<link href="../default.css" rel="stylesheet" type="text/css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<meta content="Bikeshed 1.0.0" name="generator">
<style type="text/css">
.issue th:first-child { text-align: left !important; }
[rowspan] > img { float: right; }
[rowspan] { vertical-align: middle; }
table 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="https://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" id="subtitle"><span class="content">Editor’s Draft, <time class="dt-updated" datetime="2014-12-18">18 December 2014</time></span></h2>
<div data-fill-with="spec-metadata">
<dl>
<dt>This version:
<dd><a class="u-url" href="http://dev.w3.org/csswg/css-align/">http://dev.w3.org/csswg/css-align/</a>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css-align-3/">http://www.w3.org/TR/css-align-3/</a>
<dt>Previous Versions:
<dd><a href="http://www.w3.org/TR/2013/WD-css3-align-20130514/" rel="previous">http://www.w3.org/TR/2013/WD-css3-align-20130514/</a>
<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:
<dd><span><a href="mailto:www-style@w3.org?subject=%5Bcss-align%5D%20YOUR%20TOPIC%20HERE">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>)</span>
<dt>Issue Tracking:
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/39">Tracker</a>
<dd><a href="https://github.com/w3c/csswg-drafts/issues/">GitHub</a>
<dd><a href="#issues-index">Inline In Spec</a>
<dt class="editor">Editors:
<dd class="editor p-author h-card vcard"><a class="p-name fn u-url url" href="http://fantasai.inkedblade.net/contact">Elika J. Etemad / fantasai</a> (<span class="p-org org">Invited Expert</span>)
<dd class="editor 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>)
</dl>
</div>
<div data-fill-with="warning"></div>
<p class="copyright" data-fill-with="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2014 <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href="http://ev.buaa.edu.cn/">Beihang</a>). W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply. </p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled" id="abstract"><span class="content">Abstract</span></h2>
<div class="p-summary" data-fill-with="abstract">
<p>This module contains the features of <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-link-type="biblio" href="#biblio-css3text">[CSS3TEXT]</a> and <a data-link-type="biblio" href="#biblio-css3line">[CSS3LINE]</a>.)</p>
<a href="http://www.w3.org/TR/CSS/">CSS</a> is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, in speech, etc.
</div>
<h2 class="no-num no-toc no-ref heading settled" id="status"><span class="content">Status of this document</span></h2>
<div data-fill-with="status">
<p> This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress. </p>
<p> The (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public mailing list <a href="mailto:www-style@w3.org?Subject=%5Bcss-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>
<p> This document was produced by the <a href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of the <a href="http://www.w3.org/Style/">Style Activity</a>). </p>
<p> This document was produced by a group operating under
the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href="http://www.w3.org/2004/01/pp-impl/32061/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>. </p>
<p> This document is governed by the <a href="http://www.w3.org/2015/Process-20150901/" id="w3c_process_revision">1 September 2015 W3C Process Document</a>. </p>
<p></p>
</div>
<div data-fill-with="at-risk">
<p>The following features are at-risk, and may be dropped during the CR period: </p>
<ul>
<li><a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>
</ul>
<p>“At-risk” is a W3C Process term-of-art, and does not necessarily imply that the feature is in danger of being dropped or delayed. It means that the WG believes the feature may have difficulting being interoperably implemented in a timely manner, and marking it as such allows the WG to drop the feature if necessary when transitioning to the Proposed Rec stage, without having to publish a new Candidate Rec without the feature first.</p>
</div>
<h2 class="no-num no-toc no-ref heading settled" id="contents"><span class="content">Table of Contents</span></h2>
<div data-fill-with="table-of-contents" role="navigation">
<ul class="toc" role="directory">
<li>
<a href="#intro"><span class="secno">1</span> <span class="content"> Introduction</span></a>
<ul class="toc">
<li><a href="#placement"><span class="secno">1.1</span> <span class="content"> Module interactions</span></a>
<li><a href="#values"><span class="secno">1.2</span> <span class="content"> Values</span></a>
</ul>
<li><a href="#overview"><span class="secno">2</span> <span class="content"> Overview of Alignment Properties</span></a>
<li>
<a href="#alignment-values"><span class="secno">3</span> <span class="content"> Alignment Values</span></a>
<ul class="toc">
<li><a href="#positional-values"><span class="secno">3.1</span> <span class="content"> Positional Alignment: the <span class="css">center</span>, <span class="css">start</span>, <span class="css">end</span>, <span class="css">self-start</span>, <span class="css">self-end</span>, <span class="css">flex-start</span>, <span class="css">flex-end</span>, <span class="css">left</span>, and <span class="css">right</span> keywords</span></a>
<li><a href="#baseline"><span class="secno">3.2</span> <span class="content"> Baseline Alignment: the <span class="css">baseline</span> and <span class="css">last-baseline</span> keywords</span></a>
<li><a href="#distribution-values"><span class="secno">3.3</span> <span class="content"> Distributed Alignment: the <span class="css">stretch</span>, <span class="css">space-between</span>, <span class="css">space-around</span>, and <span class="css">space-evenly</span> keywords</span></a>
<li><a href="#overflow-values"><span class="secno">3.4</span> <span class="content"> Overflow Alignment: the <span class="css">safe</span> and <span class="css">true</span> keywords</span></a>
</ul>
<li>
<a href="#content-distribution"><span class="secno">4</span> <span class="content"> Content Distribution: the <span class="property">justify-content</span> and <span class="property">align-content</span> properties</span></a>
<ul class="toc">
<li><a href="#baseline-align-content"><span class="secno">4.1</span> <span class="content"> Baseline Content-Alignment</span></a>
<li><a href="#overflow-scroll-position"><span class="secno">4.2</span> <span class="content"> Overflow and Scroll Positions</span></a>
</ul>
<li>
<a href="#self-alignment"><span class="secno">5</span> <span class="content"> Self-Alignment: Aligning the Box within its Parent</span></a>
<ul class="toc">
<li><a href="#justify-self-property"><span class="secno">5.1</span> <span class="content"> Inline/Main-Axis Alignment: the <span class="property">justify-self</span> property</span></a>
<li><a href="#align-self-property"><span class="secno">5.2</span> <span class="content"> Block/Cross-Axis Alignment: the <span class="property">align-self</span> property</span></a>
<li><a href="#baseline-align-self"><span class="secno">5.3</span> <span class="content"> Baseline Self-Alignment</span></a>
</ul>
<li>
<a href="#default-alignment"><span class="secno">6</span> <span class="content"> Default Alignment</span></a>
<ul class="toc">
<li><a href="#justify-items-property"><span class="secno">6.1</span> <span class="content"> Inline/Main-Axis Alignment: the <span class="property">justify-items</span> property</span></a>
<li><a href="#align-items-property"><span class="secno">6.2</span> <span class="content"> Block/Cross-Axis Alignment: the <span class="property">align-items</span> property</span></a>
</ul>
<li>
<a href="#baseline-rules"><span class="secno">7</span> <span class="content"> Baseline Alignment Details</span></a>
<ul class="toc">
<li><a href="#baseline-export"><span class="secno">7.1</span> <span class="content"> Determining the Baseline of a Box</span></a>
<li><a href="#baseline-terms"><span class="secno">7.2</span> <span class="content"> Baseline Alignment Terminology</span></a>
<li><a href="#align-by-baseline"><span class="secno">7.3</span> <span class="content"> Aligning Boxes by Baseline</span></a>
</ul>
<li><a href="#changes"><span class="secno">8</span> <span class="content"> Changes</span></a>
<li><a href="#acknowledgments"><span class="secno"></span> <span class="content"> Acknowledgments</span></a>
<li>
<a href="#conformance"><span class="secno"></span> <span class="content"> Conformance</span></a>
<ul class="toc">
<li><a href="#conventions"><span class="secno"></span> <span class="content"> Document conventions</span></a>
<li><a href="#conformance-classes"><span class="secno"></span> <span class="content"> Conformance classes</span></a>
<li><a href="#partial"><span class="secno"></span> <span class="content"> Partial implementations</span></a>
<li><a href="#experimental"><span class="secno"></span> <span class="content"> Experimental implementations</span></a>
<li><a href="#testing"><span class="secno"></span> <span class="content"> Non-experimental implementations</span></a>
</ul>
<li>
<a href="#index"><span class="secno"></span> <span class="content">Index</span></a>
<ul class="toc">
<li><a href="#index-defined-here"><span class="secno"></span> <span class="content">Terms defined by this specification</span></a>
<li><a href="#index-defined-elsewhere"><span class="secno"></span> <span class="content">Terms defined by reference</span></a>
</ul>
<li>
<a href="#references"><span class="secno"></span> <span class="content">References</span></a>
<ul class="toc">
<li><a href="#normative"><span class="secno"></span> <span class="content">Normative References</span></a>
<li><a href="#informative"><span class="secno"></span> <span class="content">Informative References</span></a>
</ul>
<li><a href="#property-index"><span class="secno"></span> <span class="content">Property Index</span></a>
<li><a href="#issues-index"><span class="secno"></span> <span class="content">Issues Index</span></a>
</ul>
</div>
<main>
<h2 class="heading settled" data-level="1" id="intro"><span class="secno">1. </span><span class="content"> Introduction</span><a class="self-link" href="#intro"></a></h2>
<p><em>This section is not normative.</em></p>
<p>CSS Levels 1 and 2 allowed for the alignment of text via <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-text-3/#propdef-text-align">text-align</a> and
the alignment of blocks by balancing <span class="css">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>
<p class="note" role="note">Note: The alignment of text and inline-level content is defined in <a data-link-type="biblio" href="#biblio-css3text">[CSS3TEXT]</a> and <a data-link-type="biblio" href="#biblio-css3line">[CSS3LINE]</a>.</p>
<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" 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-link-type="biblio" href="#biblio-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="https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align">vertical-align</a>, as defined in <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a> chapter 17.</p>
<p>The interaction of these properties with
Grid Layout <a data-link-type="biblio" href="#biblio-css3-grid-layout">[CSS3-GRID-LAYOUT]</a> and Flexible Box Layout <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a> is defined in their respective modules.
The property definitions here supersede those in <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a> (which have a smaller, earlier subset of permissible values).</p>
<p>No properties in this module apply to the <code>::first-line</code> or <code>::first-letter</code> pseudo-elements.</p>
<h3 class="heading settled" data-level="1.2" id="values"><span class="secno">1.2. </span><span class="content"> Values</span><a class="self-link" href="#values"></a></h3>
<p>This specification follows the <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>.
Other CSS modules may expand the definitions of these value types: for
example <a data-link-type="biblio" href="#biblio-css3val">[CSS3VAL]</a>, when combined with this module, adds the <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-cascade-3/#valdef-all-initial">initial</a> keyword as a possible property value.</p>
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a> keyword as their property value. For readability it has not been repeated
explicitly.</p>
<h2 class="heading settled" data-level="2" id="overview"><span class="secno">2. </span><span class="content"> Overview of Alignment Properties</span><a class="self-link" href="#overview"></a></h2>
<p>The <dfn data-dfn-type="dfn" data-noexport="" id="box-alignment-properties">box alignment properties<a class="self-link" href="#box-alignment-properties"></a></dfn> in CSS are a set of 6 properties
that control alignment of boxes within other boxes.
They can be described along two axises:</p>
<ul>
<li>which dimension they apply to (main/inline vs. cross/block), and
<li>whether they control the position of the box within its parent, or the box’s content within itself.
</ul>
<p class="note" role="note">Note: This specification uses the terms “justify” and “align” to distinguish
between alignment in the main/inline and cross/block 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>
<p>The following table summarizes the <a data-link-type="dfn" href="#box-alignment-properties">box alignment properties</a> and the display types they can apply to.</p>
<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
<tbody>
<tr>
<th><a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a>
<td>main/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, <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex containers</a>, and <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-container">grid containers</a>
<tr>
<th><a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a>
<td>cross/block
<td>block containers, <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex containers</a>, and <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-container">grid containers</a>
<tbody>
<tr>
<th><a class="property" data-link-type="propdesc" href="#propdef-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 <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-item">grid items</a>
<tr>
<th><a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a>
<td>cross/block
<td><a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-item">flex items</a> and <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-item">grid items</a>
<tbody>
<tr>
<th><a class="property" data-link-type="propdesc" href="#propdef-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">justify-self: auto</span>)</small>
<td><a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-container">grid containers</a>
<tr>
<th><a class="property" data-link-type="propdesc" href="#propdef-align-items">align-items</a>
<td>cross/block
<td><a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex containers</a> and <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-container">grid containers</a>
</table>
<p class="note" role="note">Note: The <a class="property" data-link-type="propdesc">*-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">*-self: auto</span> used on the items in the container element.</p>
<h2 class="heading settled" 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.</p>
<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">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">justify-self</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a>,
the <a data-link-type="dfn" href="#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">justify-content</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a>,
the <a data-link-type="dfn" href="#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">alignment container</a> is the rectangle that the <a data-link-type="dfn" href="#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">alignment subject</a>’s containing block.
</dl>
<h3 class="heading settled" 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="#valdef-self-position-center">center</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-end">end</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-self-start">self-start</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-self-end">self-end</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-flex-start">flex-start</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-flex-end">flex-end</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-left">left</a>, and <a class="css" data-link-type="maybe" href="#valdef-self-position-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">alignment subject</a> with respect to its <a data-link-type="dfn" href="#alignment-container">alignment container</a>.</p>
<p>The <a class="production css" data-link-type="type" href="#typedef-self-position" title="Expands to: right | end | center | flex-start | start | self-end | flex-end | self-start | left"><self-position></a> set of values is used by <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> to align the box within its <a data-link-type="dfn" href="#alignment-container">alignment container</a>,
and also by <a class="property" data-link-type="propdesc" href="#propdef-justify-items">justify-items</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-items">align-items</a> (to specify default values for <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a>).
The <a class="production css" data-link-type="type" href="#typedef-content-position" title="Expands to: right | end | center | flex-start | start | flex-end | left"><content-position></a> set of values is used by <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> to align the box’s contents within itself.</p>
<pre class="prod"><dfn data-dfn-type="type" data-export="" id="typedef-self-position"><self-position><a class="self-link" href="#typedef-self-position"></a></dfn> = center <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> start <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> end <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> self-start <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> self-end <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a>
flex-start <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> flex-end <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> left <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> right;
<dfn data-dfn-type="type" data-export="" id="typedef-content-position"><content-position><a class="self-link" href="#typedef-content-position"></a></dfn> = center <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> start <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> end <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> flex-start <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> flex-end <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> left <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> right;
</pre>
<p>Values have the following meanings:</p>
<dl>
<dt><dfn class="css" data-dfn-for="<self-position>, <content-position>" data-dfn-type="value" data-export="" id="valdef-self-position-center">center<a class="self-link" href="#valdef-self-position-center"></a></dfn> <small>(self, content)</small>
<dd>Centers the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> within its <a data-link-type="dfn" href="#alignment-container">alignment container</a>.
<dt><dfn class="css" data-dfn-for="<self-position>, <content-position>" data-dfn-type="value" data-export="" id="valdef-self-position-start">start<a class="self-link" href="#valdef-self-position-start"></a></dfn> <small>(self, content)</small>
<dd>Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the <a data-link-type="dfn" href="#alignment-container">alignment container</a>’s start edge.
<dt><dfn class="css" data-dfn-for="<self-position>, <content-position>" data-dfn-type="value" data-export="" id="valdef-self-position-end">end<a class="self-link" href="#valdef-self-position-end"></a></dfn> <small>(self, content)</small>
<dd>Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the <a data-link-type="dfn" href="#alignment-container">alignment container</a>’s end edge.
<dt><dfn class="css" data-dfn-for="<self-position>" data-dfn-type="value" data-export="" id="valdef-self-position-self-start">self-start<a class="self-link" href="#valdef-self-position-self-start"></a></dfn> <small>(self)</small>
<dd>Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the edge of the <a data-link-type="dfn" href="#alignment-container">alignment container</a> corresponding to the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a>’s start side.
<dt><dfn class="css" data-dfn-for="<self-position>" data-dfn-type="value" data-export="" id="valdef-self-position-self-end">self-end<a class="self-link" href="#valdef-self-position-self-end"></a></dfn> <small>(self)</small>
<dd>Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the edge of the <a data-link-type="dfn" href="#alignment-container">alignment container</a> corresponding to the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a>’s end side.
<dt><dfn class="css" data-dfn-for="<self-position>, <content-position>" data-dfn-type="value" data-export="" id="valdef-self-position-flex-start">flex-start<a class="self-link" href="#valdef-self-position-flex-start"></a></dfn> <small>(self, content)</small>
<dd><strong>Only used in flex layout.</strong> <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a> Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the edge of the <a data-link-type="dfn" href="#alignment-container">alignment container</a> corresponding to the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex container</a>’s main-start or cross-start side, as appropriate.
When used on boxes that are not children of a <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex container</a>,
this value computes to <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>.
<dt><dfn class="css" data-dfn-for="<self-position>, <content-position>" data-dfn-type="value" data-export="" id="valdef-self-position-flex-end">flex-end<a class="self-link" href="#valdef-self-position-flex-end"></a></dfn> <small>(self, content)</small>
<dd><strong>Only used in flex layout.</strong> Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the edge of the <a data-link-type="dfn" href="#alignment-container">alignment container</a> corresponding to the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex container</a>’s main-end or cross-end side, as appropriate.
When used on boxes that are not children of a <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex container</a>,
this value computes to <a class="css" data-link-type="maybe" href="#valdef-self-position-end">end</a>.
<dt><dfn class="css" data-dfn-for="<self-position>, <content-position>" data-dfn-type="value" data-export="" id="valdef-self-position-left">left<a class="self-link" href="#valdef-self-position-left"></a></dfn> <small>(self, content)</small>
<dd>Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the <a data-link-type="dfn" href="#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="#valdef-self-position-start">start</a>.
<dt><dfn class="css" data-dfn-for="<self-position>, <content-position>" data-dfn-type="value" data-export="" id="valdef-self-position-right">right<a class="self-link" href="#valdef-self-position-right"></a></dfn> <small>(self, content)</small>
<dd>Aligns the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to be flush with the <a data-link-type="dfn" href="#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="#valdef-self-position-start">start</a>.
</dl>
<p class="issue" id="issue-511afb43"><a class="self-link" href="#issue-511afb43"></a> Add example images. </p>
<p class="issue" id="issue-bb5da799"><a class="self-link" href="#issue-bb5da799"></a> Make it easier to understand the dual-axis nature of "start" and "end" wrt orthogonal flows. </p>
<h3 class="heading settled" 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="#valdef-justify-content-baseline">baseline</a> and <a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a> keywords</span><a class="self-link" href="#baseline"></a></h3>
<p><dfn data-dfn-type="dfn" data-noexport="" id="baseline-alignment">Baseline alignment<a class="self-link" href="#baseline-alignment"></a></dfn> is a form of positional alignment
that aligns multiple <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> within a <a data-link-type="dfn" href="#shared-alignment-context">shared alignment context</a> (such as cells within a row or column)
by matching up their <a data-link-type="dfn" href="#alignment-baseline">alignment baselines</a>.</p>
<p>The baseline alignment keywords are:</p>
<pre class="prod"><dfn data-dfn-type="type" data-export="" id="typedef-baseline-position"><baseline-position><a class="self-link" href="#typedef-baseline-position"></a></dfn> = baseline <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> last-baseline
</pre>
<p>and are defined below:</p>
<dl>
<dt><dfn class="css" data-dfn-for="justify-content, justify-self, justify-items, align-content, align-self, align-items, <baseline-position>" data-dfn-type="value" data-export="" id="valdef-justify-content-baseline">baseline<a class="self-link" href="#valdef-justify-content-baseline"></a></dfn>
<dd>
Indicates <dfn data-dfn-for="" data-dfn-type="dfn" data-noexport="" id="first-baseline-alignment">first-baseline alignment<a class="self-link" href="#first-baseline-alignment"></a></dfn>:
aligns one of the box’s <a data-link-type="dfn" href="#first-baselines">first baselines</a> with the corresponding <a data-link-type="dfn" href="#first-baselines">first baselines</a> of all the boxes in its <a data-link-type="dfn" href="#baseline-sharing-group">baseline-sharing group</a>.
<p>If the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a>’s position is not fully determined by <a data-link-type="dfn" href="#baseline-alignment">baseline alignment</a>,
the content is <a class="css" data-link-type="maybe" href="#valdef-self-position-self-start">self-start</a>-aligned insofar as possible while preserving the baseline alignment.
(Content that has no <a data-link-type="dfn" href="#first-baselines">first baselines</a> is thus start-aligned.)</p>
<dt><dfn class="css" data-dfn-for="justify-content, justify-self, justify-items, align-content, align-self, align-items, <baseline-position>" data-dfn-type="value" data-export="" id="valdef-justify-content-last-baseline">last-baseline<a class="self-link" href="#valdef-justify-content-last-baseline"></a></dfn>
<dd>
Indicates <dfn data-dfn-for="" data-dfn-type="dfn" data-noexport="" id="last-baseline-alignment">last-baseline alignment<a class="self-link" href="#last-baseline-alignment"></a></dfn>:
aligns one of the box’s <a data-link-type="dfn" href="#last-baselines">last baselines</a> with the corresponding <a data-link-type="dfn" href="#last-baselines">last baselines</a> of all the boxes in its <a data-link-type="dfn" href="#baseline-sharing-group">baseline-sharing group</a>.
<p>If the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a>’s position is not fully determined by <a data-link-type="dfn" href="#baseline-alignment">baseline alignment</a>,
the content is <a class="css" data-link-type="maybe" href="#valdef-self-position-self-end">self-end</a>-aligned insofar as possible while preserving the baseline alignment.
(Content that has no <a data-link-type="dfn" href="#last-baselines">last baselines</a> is thus end-aligned.)</p>
</dl>
<p>These values give a box a <dfn data-dfn-type="dfn" data-noexport="" id="baseline-alignment-preference">baseline alignment preference<a class="self-link" href="#baseline-alignment-preference"></a></dfn>:
either "first" or "last", respectively.</p>
<p>When specified for <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a>/<a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a>,
these values trigger <a data-link-type="dfn" href="#baseline-content-alignment">baseline content-alignment</a>,
shifting the content of the box within the box,
and may also affect the sizing of the box itself.
See <a href="#baseline-align-content">§4.1 Baseline Content-Alignment</a>.</p>
<p>When specified for <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a>/<a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a>,
these values trigger <a data-link-type="dfn" href="#baseline-self-alignment">baseline self-alignment</a>,
shifting the entire box within its container,
which may affect the sizing of its container.
See <a href="#baseline-align-self">§5.3 Baseline Self-Alignment</a>.</p>
<p>If both <a data-link-type="dfn" href="#baseline-content-alignment">baseline content-alignment</a> <em>and</em> <a data-link-type="dfn" href="#baseline-self-alignment">baseline self-alignment</a> are specified in the same axis on the same box,
only <a data-link-type="dfn" href="#baseline-self-alignment">baseline self-alignment</a> is honored in that axis;
the content-alignment in that axis must be treated as <a class="css" data-link-type="maybe" href="#valdef-self-position-self-start">self-start</a>.</p>
<p class="issue" id="issue-ba851208"><a class="self-link" href="#issue-ba851208"></a> The previous paragraph is fairly arbitrary.
Need some experience to make sure it’s the correct choice out of the two possibilities.</p>
<p class="issue" id="issue-13b9ed6a"><a class="self-link" href="#issue-13b9ed6a"></a>Add example images here. </p>
<p class="note" role="note">Note: The <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align">vertical-align</a> property will also need a <span class="css">first-baseline</span> value
because per CSS2.1 for inline blocks, <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> is equivalent to <a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>.</p>
<h3 class="heading settled" 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="#valdef-content-distribution-stretch">stretch</a>, <a class="css" data-link-type="maybe" href="#valdef-content-distribution-space-between">space-between</a>, <a class="css" data-link-type="maybe" href="#valdef-content-distribution-space-around">space-around</a>, and <a class="css" data-link-type="maybe" href="#valdef-content-distribution-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">justify-content</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> to distribute the <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> evenly between the start and end edges of the <a data-link-type="dfn" href="#alignment-container">alignment container</a>.
When the <a data-link-type="dfn" href="#alignment-subject">alignment subjects</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" data-link-type="type" href="#typedef-content-position" title="Expands to: right | end | center | flex-start | start | flex-end | left"><content-position></a> as a <a data-link-type="dfn" href="#fallback-alignment">fallback alignment</a>,
but one can alternatively be explicitly specified in the property.</p>
<pre class="prod"><dfn data-dfn-type="type" data-export="" id="typedef-content-distribution"><content-distribution><a class="self-link" href="#typedef-content-distribution"></a></dfn> = space-between <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> space-around <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> space-evenly <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> stretch</pre>
<dl>
<dt><dfn class="css" data-dfn-for="<content-distribution>" data-dfn-type="value" data-export="" id="valdef-content-distribution-space-between">space-between<a class="self-link" href="#valdef-content-distribution-space-between"></a></dfn>
<dd> The <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are evenly distributed in the <a data-link-type="dfn" href="#alignment-container">alignment container</a>.
The first <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is placed flush with the start edge of the <a data-link-type="dfn" href="#alignment-container">alignment container</a>,
the last <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is placed flush with the end edge of the <a data-link-type="dfn" href="#alignment-container">alignment container</a>,
and the remaining <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are distributed so that the spacing between any two adjacent <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> is the same.
Unless otherwise specified,
this value falls back to <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>.
<dt><dfn class="css" data-dfn-for="<content-distribution>" data-dfn-type="value" data-export="" id="valdef-content-distribution-space-around">space-around<a class="self-link" href="#valdef-content-distribution-space-around"></a></dfn>
<dd> The <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are evenly distributed in the <a data-link-type="dfn" href="#alignment-container">alignment container</a>,
with a half-size space on either end.
The <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are distributed so that the spacing between any two adjacent <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> is the same,
and the spacing before the first and after the last <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is half the size of the other spacing.
Unless otherwise specified,
this value falls back to <a class="css" data-link-type="maybe" href="#valdef-self-position-center">center</a>.
<dt><dfn class="css" data-dfn-for="<content-distribution>" data-dfn-type="value" data-export="" id="valdef-content-distribution-space-evenly">space-evenly<a class="self-link" href="#valdef-content-distribution-space-evenly"></a></dfn>
<dd> The <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are evenly distributed in the <a data-link-type="dfn" href="#alignment-container">alignment container</a>,
with a full-size space on either end.
The <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are distributed so that the spacing between any two adjacent <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a>,
before the first <a data-link-type="dfn" href="#alignment-subject">alignment subject</a>,
and after the last <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is the same.
Unless otherwise specified,
this value falls back to <a class="css" data-link-type="maybe" href="#valdef-self-position-center">center</a>.
<dt><dfn class="css" data-dfn-for="<content-distribution>" data-dfn-type="value" data-export="" id="valdef-content-distribution-stretch">stretch<a class="self-link" href="#valdef-content-distribution-stretch"></a></dfn>
<dd>
If the combined size of the <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> is less than the size of the <a data-link-type="dfn" href="#alignment-container">alignment container</a>,
any <span class="css">auto</span>-sized <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> have their size increased equally (not proportionally),
while still respecting the constraints imposed by <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-max-height">max-height</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-max-width">max-width</a>,
so that the combined size exactly fills the <a data-link-type="dfn" href="#alignment-container">alignment container</a>.
<p>Unless otherwise specified,
this value falls back to <a class="css" data-link-type="maybe" href="#valdef-self-position-flex-start">flex-start</a>. <span class="note" role="note">(For layout modes other than flex layout, <a class="css" data-link-type="maybe" href="#valdef-self-position-flex-start">flex-start</a> is identical to <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>.)</span></p>
<p class="issue" id="issue-3ea08feb"><a class="self-link" href="#issue-3ea08feb"></a> Should this value allow a fallback alignment on <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> and <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a>,
like it does on <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> and <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a>?</p>
</dl>
<p class="issue" id="issue-77ee454e"><a class="self-link" href="#issue-77ee454e"></a> Add even more example images. </p>
<h3 class="heading settled" 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="#valdef-overflow-position-safe">safe</a> and <a class="css" data-link-type="maybe" href="#valdef-overflow-position-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">alignment subject</a> is larger than the <a data-link-type="dfn" href="#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>
<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>
<p>If the <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a> isn’t explicitly specified,
the default <a data-link-type="dfn" href="#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">overflow alignment</a>,
while design-centric layout modes, such as flex layout, default to "true" <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a>.</p>
<pre class="prod"><dfn data-dfn-type="type" data-export="" id="typedef-overflow-position"><overflow-position><a class="self-link" href="#typedef-overflow-position"></a></dfn> = true <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> safe</pre>
<dl>
<dt><dfn class="css" data-dfn-for="<overflow-position>" data-dfn-type="value" data-export="" id="valdef-overflow-position-safe">safe<a class="self-link" href="#valdef-overflow-position-safe"></a></dfn>
<dd> If the size of the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> overflows the <a data-link-type="dfn" href="#alignment-container">alignment container</a>,
the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is instead aligned as if the alignment mode were <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>.
<dt><dfn class="css" data-dfn-for="<overflow-position>" data-dfn-type="value" data-export="" id="valdef-overflow-position-true">true<a class="self-link" href="#valdef-overflow-position-true"></a></dfn>
<dd> Regardless of the relative sizes of the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> and <a data-link-type="dfn" href="#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. </p>
<h2 class="heading settled" 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">justify-content</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> properties</span><a class="self-link" href="#content-distribution"></a></h2>
<p>The <dfn data-dfn-type="dfn" data-export="" id="content-distribution-properties">content distribution properties<a class="self-link" href="#content-distribution-properties"></a></dfn> <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> control alignment of the box’s content within the box.</p>
<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" data-link-for-hint="justify-content">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" 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" data-dfn-type="property" data-export="" id="propdef-align-content">align-content<a class="self-link" href="#propdef-align-content"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod">auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="#typedef-baseline-position" title="Expands to: last-baseline | baseline"><baseline-position></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="#typedef-content-distribution" title="Expands to: stretch | space-between | space-around | space-evenly"><content-distribution></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-any">||</a> [ <a class="production css" data-link-type="type" href="#typedef-overflow-position" title="Expands to: safe | true"><overflow-position></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-opt">?</a> && <a class="production css" data-link-type="type" href="#typedef-content-position" title="Expands to: right | end | center | flex-start | start | flex-end | left"><content-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>Percentages:
<td>n/a
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value
<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" data-dfn-for="justify-content, align-content" data-dfn-type="value" data-export="" id="valdef-justify-content-auto">auto<a class="self-link" href="#valdef-justify-content-auto"></a></dfn> are defined in <a href="#alignment-values">§3 Alignment Values</a>, above.
If both a <a class="production css" data-link-type="type" href="#typedef-content-distribution" title="Expands to: stretch | space-between | space-around | space-evenly"><content-distribution></a> and <a class="production css" data-link-type="type" href="#typedef-content-position" title="Expands to: right | end | center | flex-start | start | flex-end | left"><content-position></a> are given,
the <a class="production css" data-link-type="type" href="#typedef-content-position" title="Expands to: right | end | center | flex-start | start | flex-end | left"><content-position></a> provides an explicit <a data-link-type="dfn" href="#fallback-alignment">fallback alignment</a>.</p>
<hr>
<dl>
<dt>Block Containers:
<dd>
The <a data-link-type="dfn" href="#alignment-container">alignment container</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-display-3/#block-container">block container</a>’s content box.
The <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is the entire contents of the block, as a unit.
<p>The <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> property applies along the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>,
but if a <a class="production css" data-link-type="type" href="#typedef-content-distribution" title="Expands to: stretch | space-between | space-around | space-evenly"><content-distribution></a> is specified
the <a data-link-type="dfn" href="#fallback-alignment">fallback alignment</a> is used instead.
The <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a> property does not apply to and has no effect on block containers.</p>
<p>All values other than <a class="css" data-link-type="maybe" href="#valdef-justify-content-auto">auto</a> force the block container to establish a new formatting context.
For table cells, the behavior of the <a class="css" data-link-type="maybe" href="#valdef-justify-content-auto">auto</a> depends on the computed value of <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align">vertical-align</a>: <span class="css">top</span> makes it behave as <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>, <span class="css">middle</span> makes it behave as <a class="css" data-link-type="maybe" href="#valdef-self-position-center">center</a>, <span class="css">bottom</span> makes it behave as <a class="css" data-link-type="maybe" href="#valdef-self-position-end">end</a>,
and all other values make it behave as <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a>. <a class="css" data-link-type="maybe" href="#valdef-justify-content-auto">auto</a> otherwise behaves as <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>.</p>
<dt>Multicol Layout:
<dd>
The <a data-link-type="dfn" href="#alignment-container">alignment container</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-multicol-1/#multi_column-element">multi-column element</a>’s content box.
The <a data-link-type="dfn" href="#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">align-content</a> property applies along the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>,
but if a <a class="production css" data-link-type="type" href="#typedef-content-distribution" title="Expands to: stretch | space-between | space-around | space-evenly"><content-distribution></a> is specified
the <a data-link-type="dfn" href="#fallback-alignment">fallback alignment</a> is used instead.
The <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a> property does not apply to and has no effect on multi-column elements.</p>
<p><a class="css" data-link-type="maybe" href="#valdef-justify-content-auto">auto</a> behaves as <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>.</p>
<dt>Flex Containers:
<dd>
The <a data-link-type="dfn" href="#alignment-container">alignment container</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-container">flex container</a>’s content box.
For <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a>, the <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-item">flex items</a> in each <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-line">flex line</a>;
for <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a>, the <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-line">flex lines</a>.
<p>The <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> property applies along the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#cross-axis">cross axis</a>.</p>
<p>The <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a> property applies along the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#main-axis">main axis</a>,
but since flexing in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#main-axis">main axis</a> is controlled by <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-flexbox-1/#propdef-flex">flex</a>, <a class="css" data-link-type="maybe" href="#valdef-content-distribution-stretch">stretch</a> computes to <a class="css" data-link-type="maybe" href="#valdef-self-position-flex-start">flex-start</a>.</p>
<p><a class="css" data-link-type="maybe" href="#valdef-justify-content-auto">auto</a> behaves as <a class="css" data-link-type="maybe" href="#valdef-content-distribution-stretch">stretch</a>.</p>
<p>See <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a> for details.</p>
<p class="issue" id="issue-e1a35e68"><a class="self-link" href="#issue-e1a35e68"></a> The Flexbox spec’s legacy definition has "stretch" as the initial value,
so this is technically a behavior change.
We can instead "auto" compute to "stretch" for Flexbox if we decide it’s necessary for compat.</p>
<dt>Grid Containers:
<dd>
The <a data-link-type="dfn" href="#alignment-container">alignment container</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-container">grid container</a>’s content box.
The <a data-link-type="dfn" href="#alignment-subject">alignment subjects</a> are the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-track">grid tracks</a>.
<p>The <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> property applies along the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block (column) axis</a>,
aligning the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-row">grid rows</a>.
The <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a> property applies along the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline (row) axis</a>,
aligning the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-column">grid columns</a>.</p>
<p><a class="css" data-link-type="maybe" href="#valdef-justify-content-auto">auto</a> behaves as <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a>.</p>
<p>See <a data-link-type="biblio" href="#biblio-css3-grid-layout">[CSS3-GRID-LAYOUT]</a> for details.</p>
</dl>
<h3 class="heading settled" 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 (<a data-link-type="dfn" href="#shared-alignment-context">shared alignment contexts</a>)
can be baseline-aligned to each other.
This effectively increases the padding on the box
to align the <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> of its contents
with that of other baseline-aligned boxes in its <a data-link-type="dfn" href="#baseline-sharing-group">group</a>.</p>
<p>The set of boxes that participate in <dfn data-dfn-type="dfn" data-export="" data-lt="baseline content-alignment|first-baseline content-alignment|last-baseline content-alignment" id="baseline-content-alignment">baseline content-alignment<a class="self-link" href="#baseline-content-alignment"></a></dfn> depends on the layout model:</p>
<dl>
<dt>Table Cells:
<dd> A <a data-link-type="dfn">table cell</a> participates in first (last) <a data-link-type="dfn" href="#baseline-content-alignment">baseline content-alignment</a> in either its row or column (whichever matches its <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>)
if its computed <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> is <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> (<a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>).
<dt>Flex Items:
<dd> A <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-item">flex item</a> participates in first (last) <a data-link-type="dfn" href="#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">align-content</a> is <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> (<a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>)
and its computed <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-flexbox-1/#valdef-align-items-stretch">stretch</a> or <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a> (<a class="css" data-link-type="maybe" href="#valdef-self-position-end">end</a>).
<dt>Grid Items:
<dd> A <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-item">grid item</a> participates in first (last) <a data-link-type="dfn" href="#baseline-content-alignment">baseline content-alignment</a> in either its row or column (whichever matches its <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>)
if its computed <a class="property" data-link-type="propdesc" href="#propdef-align-content">align-content</a> is <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> (<a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>),
and its computed <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> or <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> (whichever affects its <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>) is <span class="css">stretch</span> or <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a> (<a class="css" data-link-type="maybe" href="#valdef-self-position-end">end</a>).
</dl>
<p>If a box spans multiple <a data-link-type="dfn" href="#shared-alignment-context">shared alignment contexts</a>,
it participates in first (last) <a data-link-type="dfn" href="#baseline-content-alignment">baseline content-alignment</a> within its start-most (end-most) <a data-link-type="dfn" href="#shared-alignment-context">shared alignment context</a> along that axis.</p>
<p>When a box participates in first (last) <a data-link-type="dfn" href="#baseline-content-alignment">baseline content-alignment</a> its <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is aligned to the start (end) edge of its <a data-link-type="dfn" href="#alignment-container">alignment container</a> and the minimum necessary extra space is added between its start (end) edge and the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> to match its <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> in that axis up to that of its <a data-link-type="dfn" href="#baseline-sharing-group">baseline-sharing group</a>.
See <a href="#align-by-baseline">§7.3 Aligning Boxes by Baseline</a>.
This increases the intrinsic size of the box.</p>
<p class="issue" id="issue-679a9755"><a class="self-link" href="#issue-679a9755"></a> Make that last paragraph more readable.</p>
<h3 class="heading settled" data-level="4.2" id="overflow-scroll-position"><span class="secno">4.2. </span><span class="content"> Overflow and Scroll Positions</span><a class="self-link" href="#overflow-scroll-position"></a></h3>
<p>The <a data-link-type="dfn" href="#content-distribution-properties">content distribution properties</a> also affect the initial scroll position,
setting it to display the appropriate portion of the scrollable area.
In other words,
the scrollable area is aligned relative to the viewport
as specified by the <a data-link-type="dfn" href="#content-distribution-properties">content distribution property</a>.</p>
<div class="example" id="example-a104fac2"><a class="self-link" href="#example-a104fac2"></a> For example,
if a scrollable flex container is set to <a class="css" data-link-type="propdesc" href="#propdef-justify-content">justify-content: flex-end</a> (or <a class="css" data-link-type="propdesc" href="#propdef-justify-content">justify-content: flex-start</a> with <a class="css" data-link-type="propdesc" href="https://drafts.csswg.org/css-flexbox-1/#propdef-flex-flow">flex-flow: row-reverse</a>),
it will be initially displayed scrolled all the way to the main-end edge of the scrollable area,
and its content will overflow its main-start edge. </div>
<p class="issue" id="issue-f2f93187"><a class="self-link" href="#issue-f2f93187"></a> This needs to be integrated with overflow-anchor, when the property exists,
so that you get the same behavior whether an elements *starts out* overflowing,
or is filled element-by-element.</p>
<h2 class="heading settled" 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">justify-self</a> and <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> properties control alignment of the box within its containing block.</p>
<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" 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">justify-self</a> property</span><a class="self-link" href="#justify-self-property"></a></h3>
<table class="definition propdef" data-link-for-hint="justify-self">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-justify-self">justify-self<a class="self-link" href="#propdef-justify-self"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod">auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> stretch <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="#typedef-baseline-position" title="Expands to: last-baseline | baseline"><baseline-position></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> [ <a class="production css" data-link-type="type" href="#typedef-overflow-position" title="Expands to: safe | true"><overflow-position></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-opt">?</a> && <a class="production css" data-link-type="type" href="#typedef-self-position" title="Expands to: right | end | center | flex-start | start | self-end | flex-end | self-start | left"><self-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>Percentages:
<td>n/a
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value, except for <a class="css" data-link-type="maybe" href="#valdef-justify-self-auto">auto</a> (see prose)
<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">alignment container</a> <a href="#alignment-values">as described by its alignment value</a>.</p>
<p>The <dfn class="css" data-dfn-for="justify-self" data-dfn-type="value" data-export="" id="valdef-justify-self-auto">auto<a class="self-link" href="#valdef-justify-self-auto"></a></dfn> keyword computes to
itself on absolutely-positioned elements,
and to the computed value of <a class="property" data-link-type="propdesc" href="#propdef-justify-items">justify-items</a> on the parent
(minus any <a class="css" data-link-type="maybe" href="#valdef-justify-items-legacy">legacy</a> keywords) on all other boxes,
or <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a> if the box has no parent.
Its behavior depends on the layout model, as described below.</p>
<p>When the box’s computed <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-width">width</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-height">height</a> (as appropriate to the axis) is <span class="css">auto</span> and neither of its margins (in the appropriate axis) are <span class="css">auto</span>,
the <dfn data-dfn-for="justify-self, align-self" data-dfn-type="dfn" data-noexport="" id="stretch">stretch<a class="self-link" href="#stretch"></a></dfn> keyword
sets the box’s used size to the length necessary to make its outer size
as close to filling the <a data-link-type="dfn" href="#alignment-container">alignment container</a> as possible
while still respecting the constraints imposed by <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-min-height">min-height</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-min-width">min-width</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-max-height">max-height</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css2/visudet.html#propdef-max-width">max-width</a>.
Unless otherwise specified, this value falls back to <a class="css" data-link-type="maybe" href="#valdef-self-position-flex-start">flex-start</a>.</p>
<p>All other values are as defined in <a href="#alignment-values">§3 Alignment Values</a>, above.</p>
<hr>
<dl>
<dt>Block-level Boxes:
<dd>
The <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> property applies along its containing block’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>.
<p>The <a data-link-type="dfn" href="#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">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">alignment subject</a> is the block’s margin box.</p>
<p>The default <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a> is <a class="css" data-link-type="maybe" href="#valdef-overflow-position-safe">safe</a>.
In terms of CSS2.1 block-level formatting <a data-link-type="biblio" href="#biblio-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>
<p>This property does not apply to floats.</p>
<dt>Absolutely-positioned Boxes:
<dd>
The <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> property applies along its containing block’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>.
<p>If either margin in this dimension is <span class="css">auto</span>,
or either offset property in this dimension is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-position-3/#valdef-top-auto">auto</a>, <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> has no effect.
Otherwise, its effects are defined below.</p>
<p>The <a class="css" data-link-type="maybe" href="#valdef-justify-self-auto">auto</a> keyword behaves as <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a> on replaced absolutely-positioned boxes,
and behaves as <span class="css">stretch</span> on all other absolutely-positioned boxes.
(This is because CSS 2.1 does not stretch replaced elements to fit into fixed offsets.)</p>
<p>Values other than <span class="css">stretch</span> 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">auto</span> measures.</p>
<p>The <a data-link-type="dfn" href="#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="https://drafts.csswg.org/css-position-3/#propdef-top">top</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-right">right</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-bottom">bottom</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-left">left</a>).
The <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is the box’s margin box.</p>
<p>The default <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a> is <a class="css" data-link-type="maybe" href="#valdef-overflow-position-safe">safe</a>.
In terms of CSS2.1 formatting <a data-link-type="biblio" href="#biblio-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>
<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="https://drafts.csswg.org/css-flexbox-1/#flex-item">flex items</a>,
because there is more than one item in the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#main-axis">main axis</a>.
See <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-flexbox-1/#propdef-flex">flex</a> for stretching and <a class="property" data-link-type="propdesc" href="#propdef-justify-content">justify-content</a> for <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#main-axis">main-axis</a> alignment. <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a>
<dt>Grid Items:
<dd>
The <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> property applies along the grid’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#row-axis">row axis</a>.
<p>The <a data-link-type="dfn" href="#alignment-container">alignment container</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-area">grid area</a>.
The <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-item">grid item</a>’s margin box.
The default <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a> is <a class="css" data-link-type="maybe" href="#valdef-overflow-position-true">true</a>.</p>
</dl>
<div class="example" id="example-098c9ed3"><a class="self-link" href="#example-098c9ed3"></a> 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" 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">align-self</a> property</span><a class="self-link" href="#align-self-property"></a></h3>
<table class="definition propdef" data-link-for-hint="align-self">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-align-self">align-self<a class="self-link" href="#propdef-align-self"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod">auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> stretch <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="#typedef-baseline-position" title="Expands to: last-baseline | baseline"><baseline-position></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> [ <a class="production css" data-link-type="type" href="#typedef-overflow-position" title="Expands to: safe | true"><overflow-position></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-opt">?</a> && <a class="production css" data-link-type="type" href="#typedef-self-position" title="Expands to: right | end | center | flex-start | start | self-end | flex-end | self-start | left"><self-position></a> ]
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>flex items, grid items, and absolutely-positioned boxes
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>n/a
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value, except for <a class="css" data-link-type="maybe" href="#valdef-align-self-auto">auto</a> (see prose)
<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">alignment container</a> <a href="#alignment-values">as described by its alignment value</a>.</p>
<p>The <dfn class="css" data-dfn-for="align-self" data-dfn-type="value" data-export="" id="valdef-align-self-auto">auto<a class="self-link" href="#valdef-align-self-auto"></a></dfn> keyword computes to
itself on absolutely-positioned elements,
and to the computed value of <a class="property" data-link-type="propdesc" href="#propdef-align-items">align-items</a> on the parent
(minus any <a class="css" data-link-type="maybe" href="#valdef-justify-items-legacy">legacy</a> keywords) on all other boxes,
or <span class="css">start</span> if the box has no parent.
Its behavior depends on the layout model, as described for <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a>.</p>
<p>The <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-flexbox-1/#valdef-align-items-stretch">stretch</a> keyword is as defined in <a href="#justify-self-property">§5.1 Inline/Main-Axis Alignment: the justify-self property</a>.</p>
<p>All other values are as defined in <a href="#alignment-values">§3 Alignment Values</a>, above.</p>
<hr>
<dl>
<dt>Block-level Boxes:
<dd> The <a class="property" data-link-type="propdesc" href="#propdef-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="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>.
<dt>Absolutely-positioned Boxes:
<dd>
The <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> property applies along its containing block’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>.
<p>When neither margin in this dimension is <span class="css">auto</span> and neither offset property in this dimension is <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-position-3/#valdef-top-auto">auto</a>,
values other than <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-flexbox-1/#valdef-align-items-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">auto</span> measures,
and <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> dictates alignment as follows:</p>
<p class="issue" id="issue-604fd27b"><a class="self-link" href="#issue-604fd27b"></a> When you have non-auto left/right and auto width,
legacy behavior stretches the width and ignores margins.
We should keep "auto" around for abspos,
and have it do this legacy behavior.
Any other value (including "stretch") should do standard "auto margins get first dibs" behavior.</p>
<p>The <a data-link-type="dfn" href="#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="https://drafts.csswg.org/css-position-3/#propdef-top">top</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-right">right</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-bottom">bottom</a>/<a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-position-3/#propdef-left">left</a>).
The <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is the box’s margin box.</p>
<p>The default <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a> is <a class="css" data-link-type="maybe" href="#valdef-overflow-position-safe">safe</a>.
In terms of CSS2.1 formatting <a data-link-type="biblio" href="#biblio-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>
<p>The <a class="css" data-link-type="maybe" href="#valdef-align-self-auto">auto</a> keyword is equivalent to <a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a> on replaced absolutely-positioned boxes,
and equivalent to <a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-flexbox-1/#valdef-align-items-stretch">stretch</a> on all other absolutely-positioned boxes.
(This is because CSS 2.1 does not stretch replaced elements to fit into fixed offsets.)</p>
<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">align-self</a> property applies along the flexbox’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#cross-axis">cross axis</a>.
<p>The <a data-link-type="dfn" href="#alignment-container">alignment container</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-line">flex line</a> the item is in.
The <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-item">flex item</a>’s margin box.
The default <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a> is <a class="css" data-link-type="maybe" href="#valdef-overflow-position-true">true</a>.
See <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a> for details.</p>
<dt>Grid Items:
<dd>
The <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> property applies along the grid’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#column-axis">column axis</a>.
<p>The <a data-link-type="dfn" href="#alignment-container">alignment container</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-area">grid area</a>.
The <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-item">grid item</a>’s margin box.
The default <a data-link-type="dfn" href="#overflow-alignment">overflow alignment</a> is <a class="css" data-link-type="maybe" href="#valdef-overflow-position-true">true</a>.</p>
</dl>
<h3 class="heading settled" 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 (<a data-link-type="dfn" href="#shared-alignment-context">shared alignment contexts</a>)
can be baseline-aligned to each other.
This effectively increases the margins on the box
to align its <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> with other baseline-aligned boxes in its <a data-link-type="dfn" href="#baseline-sharing-group">group</a>.</p>
<p>The set of boxes that participate in <dfn data-dfn-type="dfn" data-export="" data-lt="baseline self-alignment|first-baseline self-alignment|last-baseline self-alignment" id="baseline-self-alignment">baseline self-alignment<a class="self-link" href="#baseline-self-alignment"></a></dfn> depends on the layout model:</p>
<dl>
<dt>Flex Items:
<dd> A <a data-link-type="dfn" href="https://drafts.csswg.org/css-flexbox-1/#flex-item">flex item</a> participates in first (last) <a data-link-type="dfn" href="#baseline-self-alignment">baseline self-alignment</a> in its flex line
if its computed <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> is <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> (<a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>).
See <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a> for details.
<dt>Grid Items:
<dd> A <a data-link-type="dfn" href="https://drafts.csswg.org/css-grid-1/#grid-item">grid item</a> participates in first (last) <a data-link-type="dfn" href="#baseline-self-alignment">baseline self-alignment</a> in either its row or column (whichever matches its <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>)
if its <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> or <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> property (whichever affects its <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-axis">block axis</a>)
computes to <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> (<a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>).
</dl>
<p>If a box spans multiple <a data-link-type="dfn" href="#shared-alignment-context">shared alignment contexts</a>,
it participates in first (last) <a data-link-type="dfn" href="#baseline-self-alignment">baseline self-alignment</a> within its start-most (end-most) <a data-link-type="dfn" href="#shared-alignment-context">shared alignment context</a> along that axis.</p>
<p>When a box participates in first (last) <a data-link-type="dfn" href="#baseline-self-alignment">baseline self-alignment</a> its <a data-link-type="dfn" href="#alignment-subject">alignment subject</a> is aligned to the start (end) edge of its <a data-link-type="dfn" href="#alignment-container">alignment container</a> and the minimum necessary extra space is added between its start (end) edge and the <a data-link-type="dfn" href="#alignment-container">alignment container</a> to match its <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> in that axis up to that of its <a data-link-type="dfn" href="#baseline-sharing-group">baseline-sharing group</a>.
See <a href="#align-by-baseline">§7.3 Aligning Boxes by Baseline</a>.
This may increase the intrinsic size contribution of the <a data-link-type="dfn" href="#alignment-subject">alignment subject</a>.</p>
<h2 class="heading settled" 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">align-items</a> and <a class="property" data-link-type="propdesc" href="#propdef-justify-items">justify-items</a> properties set the default <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a> and <a class="property" data-link-type="propdesc" href="#propdef-justify-self">justify-self</a> behavior of the items contained by the element.</p>
<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" 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">justify-items</a> property</span><a class="self-link" href="#justify-items-property"></a></h3>
<table class="definition propdef" data-link-for-hint="justify-items">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-justify-items">justify-items<a class="self-link" href="#propdef-justify-items"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod">auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> stretch <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="#typedef-baseline-position" title="Expands to: last-baseline | baseline"><baseline-position></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> [ <a class="production css" data-link-type="type" href="#typedef-self-position" title="Expands to: right | end | center | flex-start | start | self-end | flex-end | self-start | left"><self-position></a> && <a class="production css" data-link-type="type" href="#typedef-overflow-position" title="Expands to: safe | true"><overflow-position></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-opt">?</a> ] <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> [ legacy && [ <a class="css" data-link-type="maybe" href="#valdef-self-position-left">left</a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="css" data-link-type="maybe" href="#valdef-self-position-right">right</a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="css" data-link-type="maybe" href="#valdef-self-position-center">center</a> ] ]
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block containers and grid containers
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>n/a
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value, except for <a class="css" data-link-type="maybe" href="#valdef-justify-items-auto">auto</a> (see prose)
<tr>
<th>Animatable:
<td>no
</table>
<p>This property specifies the default <a class="property" data-link-type="propdesc" href="#propdef-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:</p>
<dl>
<dt><dfn class="css" data-dfn-for="justify-items" data-dfn-type="value" data-export="" id="valdef-justify-items-auto">auto<a class="self-link" href="#valdef-justify-items-auto"></a></dfn>
<dd>
If the <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-4/#inherited-value">inherited value</a> of <span class="css">justify-items</span> includes the <a class="css" data-link-type="maybe" href="#valdef-justify-items-legacy">legacy</a> keyword, <a class="css" data-link-type="maybe" href="#valdef-justify-items-auto">auto</a> computes to the <a data-link-type="dfn" href="https://drafts.csswg.org/css-cascade-4/#inherited-value">inherited value</a>.
<p>Otherwise, <a class="css" data-link-type="maybe" href="#valdef-justify-items-auto">auto</a> computes to:</p>
<ul>
<li><span class="css">stretch</span> for flex containers and grid containers
<li><a class="css" data-link-type="maybe" href="#valdef-self-position-start">start</a> for everything else
</ul>
<dt><dfn class="css" data-dfn-for="justify-items" data-dfn-type="value" data-export="" id="valdef-justify-items-legacy">legacy<a class="self-link" href="#valdef-justify-items-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="#valdef-self-position-center">center</a>, <a class="css" data-link-type="maybe" href="#valdef-self-position-left">left</a>, and <a class="css" data-link-type="maybe" href="#valdef-self-position-right">right</a> positions.
When <span class="css">justify-self:auto</span> retrieves the value of <a class="property" data-link-type="propdesc" href="#propdef-justify-items">justify-items</a>,
only the alignment keyword, not the <a class="css" data-link-type="maybe" href="#valdef-justify-items-legacy">legacy</a> keyword, is passed to it.
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">justify-self</a>.</p>
<h3 class="heading settled" 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">align-items</a> property</span><a class="self-link" href="#align-items-property"></a></h3>
<table class="definition propdef" data-link-for-hint="align-items">
<tbody>
<tr>
<th>Name:
<td><dfn class="css" data-dfn-type="property" data-export="" id="propdef-align-items">align-items<a class="self-link" href="#propdef-align-items"></a></dfn>
<tr class="value">
<th>Value:
<td class="prod">auto <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> stretch <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> <a class="production css" data-link-type="type" href="#typedef-baseline-position" title="Expands to: last-baseline | baseline"><baseline-position></a> <a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#comb-one">|</a> [ <a class="production css" data-link-type="type" href="#typedef-self-position" title="Expands to: right | end | center | flex-start | start | self-end | flex-end | self-start | left"><self-position></a> && <a class="production css" data-link-type="type" href="#typedef-overflow-position" title="Expands to: safe | true"><overflow-position></a><a data-link-type="grammar" href="https://drafts.csswg.org/css-values-3/#mult-opt">?</a> ]
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block-level elements
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>n/a
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value, except for <a class="css" data-link-type="maybe" href="#valdef-align-items-auto">auto</a> (see prose)
<tr>
<th>Animatable:
<td>no
</table>
<p>This property specifies the default <a class="property" data-link-type="propdesc" href="#propdef-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:</p>
<dl>
<dt><dfn class="css" data-dfn-for="align-items" data-dfn-type="value" data-export="" id="valdef-align-items-auto">auto<a class="self-link" href="#valdef-align-items-auto"></a></dfn>
<dd>
Computes to:
<ul>
<li><a class="css" data-link-type="maybe" href="https://drafts.csswg.org/css-flexbox-1/#valdef-align-items-stretch">stretch</a> for flex containers and grid containers
<li><a class="css" data-link-type="maybe" href="#valdef-self-position-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">align-self</a>.</p>
<h2 class="heading settled" data-level="7" id="baseline-rules"><span class="secno">7. </span><span class="content"> Baseline Alignment Details</span><a class="self-link" href="#baseline-rules"></a></h2>
<h3 class="heading settled" data-level="7.1" id="baseline-export"><span class="secno">7.1. </span><span class="content"> Determining the Baseline of a Box</span><a class="self-link" href="#baseline-export"></a></h3>
<p>The <dfn data-dfn-type="dfn" data-export="" data-lt="first baselines|baselines of a box" id="first-baselines">first baselines<a class="self-link" href="#first-baselines"></a></dfn> (and <dfn data-dfn-type="dfn" data-export="" id="last-baselines">last baselines<a class="self-link" href="#last-baselines"></a></dfn>) of a box
for a given axis
are a set of baselines (alphabetic, central, etc.)
nominally associated with the first (last) line of text within the box.
The <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> is one of these,
usually the dominant baseline of the <a data-link-type="dfn" href="#alignment-container">alignment container</a>.
(See <a class="property" data-link-type="propdesc" href="https://svgwg.org/svg2-draft/text.html#AlignmentBaselineProperty">alignment-baseline</a>.)
Note that boxes might not have baselines in a particular axis.</p>
<p>The first and last <a data-link-type="dfn" href="#first-baselines">baselines of a box</a> are determined differently based on the layout model, as follows:</p>
<dl>
<dt>block containers
<dd>
The first (last) inline-axis baselines of a block container
are <a data-link-type="dfn" href="#generate-baselines">generated</a> from the dominant first (last) baseline of the first (last) in-flow line box in the block container,
or are taken from the first (last) in-flow block-level child in the block container that contributes a set of first (last) baselines,
whichever comes first (last).
If there is no such line box or child,
then the block container has no baselines.
For the purposes of finding the baselines,
in-flow boxes with a scrolling mechanisms (see the <a class="property" data-link-type="propdesc" href="https://drafts.csswg.org/css-overflow-3/#propdef-overflow">overflow</a> property)
must be considered as if scrolled to their origin (final) position.
<p>A block container has no block-axis baselines.</p>
<dt>tables
<dd>
The first (last) inline-axis baselines of a table box are
the first (last) baselines of its first (last) row.
<p>When finding the baselines of an inline-block,
any baselines contributed by table boxes must be skipped.
(This quirk is a legacy behavior from <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>.)</p>
<p>The first (last) block-axis baselines of a table box are the first (last) baselines of its first (last) column.</p>
<dt>table rows
<dd>
If any cells in the row participate in <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> (<a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>) alignment along the row axis,
the first (last) inline-axis baselines of the row
are <a data-link-type="dfn" href="#generate-baselines">generated</a> from their shared <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> and the row’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-fonts-3/#first-available-font">first available font</a>,
after alignment has been performed.
Otherwise, the first (last) inline-axis baselines of the row
are <a data-link-type="dfn" href="#synthesize-baselines">synthesized</a> from the lowest and highest content edges of the cells in the row. <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>
<p>A table row has no block-axis baselines.</p>
<dt>table columns
<dd>
If any cells in the column participate in <a class="css" data-link-type="maybe" href="#valdef-justify-content-baseline">baseline</a> (<a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a>) alignment
along the column axis (by having a writing mode perpendicular to that of the table),
the first (last) block-axis baselines of the column
are <a data-link-type="dfn" href="#generate-baselines">generated</a> from their shared <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> and the column’s <a data-link-type="dfn" href="https://drafts.csswg.org/css-fonts-3/#first-available-font">first available font</a>,
after alignment has been performed.
Otherwise, the first (last) inline-axis baselines of the row
are <a data-link-type="dfn" href="#synthesize-baselines">synthesized</a> from the extreme content edges of the cells in the row. <a data-link-type="biblio" href="#biblio-css21">[CSS21]</a>
<p>A table column has no inline-axis baselines.</p>
<dt>flex containers
<dd> See <a href="http://www.w3.org/TR/css3-flexbox/#flex-baselines">Flex Baselines</a> in <a data-link-type="biblio" href="#biblio-css3-flexbox">[CSS3-FLEXBOX]</a>.
<dt>grid containers
<dd> See <a href="http://www.w3.org/TR/css3-grid-layout/#grid-baselines">Grid Baselines</a> in <a data-link-type="biblio" href="#biblio-css3-grid-layout">[CSS3-GRID-LAYOUT]</a>.
</dl>
<p>To <dfn data-dfn-type="dfn" data-local-lt="generate|generated" data-noexport="" id="generate-baselines">generate baselines<a class="self-link" href="#generate-baselines"></a></dfn> for a box from a single baseline,
use the baseline table from the font settings and <a data-link-type="dfn" href="https://drafts.csswg.org/css-fonts-3/#first-available-font">first available font</a> of that box,
and align that baseline set to the given single baseline.</p>
<p>To <dfn data-dfn-type="dfn" data-local-lt="synthesize|synthesized" data-noexport="" id="synthesize-baselines">synthesize baselines<a class="self-link" href="#synthesize-baselines"></a></dfn> from a rectangle (or two parallel lines),
synthesize the alphabetic baseline from the lower line
and the central baseline by averaging the positions of the upper and lower lines.</p>
<p class="note" role="note">Note: The forthcoming Inline Layout Module will define synthesis rules for baselines other than alphabetic and central.</p>
<p class="issue" id="issue-cfbec8b9"><a class="self-link" href="#issue-cfbec8b9"></a> Maybe these things are wrong?
CSS 2.1 is really weird about baseline alignment. </p>
<h3 class="heading settled" data-level="7.2" id="baseline-terms"><span class="secno">7.2. </span><span class="content"> Baseline Alignment Terminology</span><a class="self-link" href="#baseline-terms"></a></h3>
<p>A <dfn data-dfn-type="dfn" data-noexport="" id="baseline-sharing-group">baseline-sharing group<a class="self-link" href="#baseline-sharing-group"></a></dfn> is composed of boxes that participate in baseline alignment together.
This is possible only if they</p>
<ul>
<li>share an <a data-link-type="dfn" href="#shared-alignment-context">alignment context</a> whose axis is parallel to their <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#inline-axis">inline axis</a>
<li>either have the same <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-flow-direction">block flow direction</a> and <a data-link-type="dfn" href="#baseline-alignment-preference">baseline alignment preference</a>,
or have opposite <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#block-flow-direction">block flow direction</a> and opposite <a data-link-type="dfn" href="#baseline-alignment-preference">baseline alignment preference</a> (in other words, the baselines that want to align are on the same side of the alignment context).
</ul>
<p>Boxes <dfn data-dfn-type="dfn" data-lt="shared alignment context|alignment context" data-noexport="" id="shared-alignment-context">share an alignment context<a class="self-link" href="#shared-alignment-context"></a></dfn> along a particular axis when they are:</p>
<ul>
<li>table cells in the same row, along the table’s row (inline) axis
<li>table cells in the same column, along the table’s column (block) axis
<li>grid items in the same row, along the grid’s row (inline) axis
<li>grid items in the same column, along the grid’s colum (block) axis
<li>flex items in the same flex line, along the flex container’s main axis
</ul>
<p>Boxes in a <a data-link-type="dfn" href="#baseline-sharing-group">baseline-sharing group</a> are aligned to each other
using their <dfn data-dfn-type="dfn" data-noexport="" id="alignment-baseline">alignment baseline<a class="self-link" href="#alignment-baseline"></a></dfn>.
This is the dominant baseline associated with
the box that generates their <a data-link-type="dfn" href="#shared-alignment-context">shared alignment context</a> on the first (last, for <a class="css" data-link-type="maybe" href="#valdef-justify-content-last-baseline">last-baseline</a> alignment) <a data-link-type="dfn" href="https://drafts.csswg.org/selectors-3/#first-formatted-line0">formatted line</a>.
For example, in horizontal writing modes,
specifying <a class="css" data-link-type="propdesc" href="#propdef-align-content">align-content: baseline</a> on table cells in the same row
will align the alphabetic baselines of their <a data-link-type="dfn" href="https://drafts.csswg.org/selectors-3/#first-formatted-line0">first formatted lines</a>.</p>
<h3 class="heading settled" data-level="7.3" id="align-by-baseline"><span class="secno">7.3. </span><span class="content"> Aligning Boxes by Baseline</span><a class="self-link" href="#align-by-baseline"></a></h3>
<p>Given a set of boxes and their baselines that all belong to a single <a data-link-type="dfn" href="#baseline-sharing-group">baseline-sharing group</a>,
the boxes are baseline-aligned as follows:</p>
<p>First, generate the alignment context’s baseline table
from its <a data-link-type="dfn" href="https://drafts.csswg.org/css-fonts-3/#first-available-font">first available font</a> and overlay also the mirror of this baseline table by aligning their central baselines.
These are the baseline grids to which the boxes will align.</p>
<p>Next, align all boxes by their specified <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> to the alignment context’s baseline table
or its mirror, whichever matches its <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#line-orientation">line orientation</a>.
Unless otherwise specified (e.g. via the <a class="property" data-link-type="propdesc" href="https://svgwg.org/svg2-draft/text.html#AlignmentBaselineProperty">alignment-baseline</a> property),
the <a data-link-type="dfn" href="#alignment-baseline">alignment baseline</a> is the <a data-link-type="dfn" href="https://drafts.csswg.org/css-writing-modes-3/#dominant-baseline">dominant baseline</a> of the alignment context.</p>
<p>Position this <dfn data-dfn-type="dfn" data-noexport="" id="aligned-subtree">aligned subtree<a class="self-link" href="#aligned-subtree"></a></dfn> within the alignment container
according to the rules of the <a data-link-type="dfn" href="#box-alignment-properties">box alignment properties</a> in effect.</p>
<h2 class="heading settled" data-level="8" id="changes"><span class="secno">8. </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/2014/WD-css-align-3-20141218/">previous Working Draft</a> include:</p>
<ul>
<li data-md="">
<p>Fixed handling of <a class="css" data-link-type="propdesc" href="#propdef-justify-self">justify-self: stretch</a> (and <a class="property" data-link-type="propdesc" href="#propdef-align-self">align-self</a>) to allow shrinking, as defined in Flexbox.</p>
<li data-md="">
<p>Made justify/align-content:auto computte to their respective behaviors for flex and grid containers.</p>
</ul>
<h2 class="no-num heading settled" id="acknowledgments"><span class="content"> Acknowledgments</span><a class="self-link" href="#acknowledgments"></a></h2>
<p>Special thanks goes to Javier Fernandez, Markus Mielke, Alex Mogilevsky,
and the participants in the CSSWG’s March 2008 F2F alignment discussions.</p>
</main>
<h2 class="no-ref no-num heading settled" id="conformance"><span class="content"> Conformance</span><a class="self-link" href="#conformance"></a></h2>
<h3 class="no-ref heading settled" 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