forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.html
More file actions
executable file
·1594 lines (1142 loc) · 51.9 KB
/
Copy pathOverview.html
File metadata and controls
executable file
·1594 lines (1142 loc) · 51.9 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>
<link href="#contents" rel=contents>
<link href="#index" rel=index>
<link href="../default.css" rel=stylesheet type="text/css">
<link href="http://www.w3.org/StyleSheets/TR/W3C-WD.css" rel=stylesheet
type="text/css">
<style type="text/css">
body, html { max-width: 85em; }
.issue th:first-child { text-align: left !important; }
[rowspan] > img { max-height: 4em; float: right; }
[rowspan] { vertical-align: middle; }
small { display: block; }
</style>
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS Box Alignment Module Level 3</h1>
<h2 class="no-num no-toc" id=longstatus-date>W3C Working Draft 12 June
2012</h2>
<dl>
<dt>This version:
<dd><a
href="http://www.w3.org/TR/2012/WD-css3-align-20120612/">http://www.w3.org/TR/2012/WD-css3-align-20120612/</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-align/">http://www.w3.org/TR/css3-align/</a>
<dt>Editor's draft:
<dd><a
href="http://dev.w3.org/csswg/css3-align/">http://dev.w3.org/csswg/css3-align/</a>
<dt>Previous version:
<dd>— <!--
<dt>Issue Tracking:</dt>
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/FIXME">http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
-->
<dt>Feedback:
<dd><a
href="http://lists.w3.org/Archives/Public/www-style/">www-style@w3.org</a>
with subject line “<kbd>[css3-align] <var>… message topic
…</var></kbd>”
<dt>Editors:
<dd class="h-card vcard"> <a class="p-name fn u-url url"
href="http://fantasai.inkedblade.net/contact" rel=author>Elika J.
Etemad</a>, <span class="p-org org">Mozilla</span>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2012 <a href="http://www.w3.org/"><abbr
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><abbr
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
href="http://www.ercim.eu/"><abbr
title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>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 href="#CSS3TEXT"
>[CSS3TEXT]<!--{{CSS3TEXT}}--></a> and [[CSS3LINEBOX]].)
CSS is a language for describing the rendering of structured documents
(such as HTML and XML) on screen, on paper, in speech, etc.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-status-->
<p><em>This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
index at http://www.w3.org/TR/.</a></em>
<p>Publication as a Working Draft does not imply endorsement by the W3C
Membership. This is a draft document and may be updated, replaced or
obsoleted by other documents at any time. It is inappropriate to cite this
document as other than work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a href="mailto:www-style@w3.org">www-style@w3.org</a> (see
<a href="http://www.w3.org/Mail/Request">instructions</a>) is preferred
for discussion of this specification. When sending e-mail, please put the
text “css3-align” in the subject, preferably like this:
“[<!---->css3-align<!---->] <em>…summary of comment…</em>”
<p>This document was produced by the <a
href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of
the <a href="http://www.w3.org/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<!--end-status-->
<p>The following features are at risk: …
<h2 class="no-num no-toc" id=contents> Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#intro"><span class=secno>1. </span> Introduction</a>
<ul class=toc>
<li><a href="#placement"><span class=secno>1.1. </span> Module
interactions</a>
<li><a href="#values"><span class=secno>1.2. </span> Values</a>
</ul>
<li><a href="#overview"><span class=secno>2. </span> Overview of Alignment
Properties</a>
<li><a href="#self-alignment"><span class=secno>3. </span> Self-Alignment:
Aligning the Box within its Parent</a>
<ul class=toc>
<li><a href="#justify-self"><span class=secno>3.1. </span>
Inline/Main-Axis Alignment: the ‘<code
class=property>justify-self</code>’ property</a>
<li><a href="#align-self"><span class=secno>3.2. </span>
Stacking/Cross-Axis Alignment: the ‘<code
class=property>align-self</code>’ property</a>
</ul>
<li><a href="#content-alignment"><span class=secno>4. </span>
Content-Alignment: Aligning the Content within the Box</a>
<ul class=toc>
<li><a href="#justify-content"><span class=secno>4.1. </span>
Inline/Main-Axis Alignment: the ‘<code
class=property>justify-content</code>’ property</a>
<li><a href="#align-content"><span class=secno>4.2. </span>
Stacking/Cross-Axis Alignment: the ‘<code
class=property>align-content</code>’ property</a>
</ul>
<li><a href="#default-alignment"><span class=secno>5. </span> Default
Alignment of Child Items</a>
<ul class=toc>
<li><a href="#justify-items"><span class=secno>5.1. </span>
Inline/Main-Axis Alignment: the ‘<code
class=property>justify-items</code>’ property</a>
<li><a href="#align-items"><span class=secno>5.2. </span>
Stacking/Cross-Axis Alignment: the ‘<code
class=property>align-items</code>’ property</a>
</ul>
<li><a href="#conformance"><span class=secno>6. </span> Conformance</a>
<ul class=toc>
<li><a href="#conventions"><span class=secno>6.1. </span> Document
conventions</a>
<li><a href="#conformance-classes"><span class=secno>6.2. </span>
Conformance classes</a>
<li><a href="#partial"><span class=secno>6.3. </span> Partial
implementations</a>
<li><a href="#experimental"><span class=secno>6.4. </span> Experimental
implementations</a>
<li><a href="#testing"><span class=secno>6.5. </span> Non-experimental
implementations</a>
<li><a href="#cr-exit-criteria"><span class=secno>6.6. </span> CR exit
criteria</a>
</ul>
<li class=no-num><a href="#acknowledgments"> Acknowledgments</a>
<li class=no-num><a href="#references"> References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references"> Normative
references</a>
<li class=no-num><a href="#other-references"> Other references</a>
</ul>
<li class=no-num><a href="#index"> Index</a>
<li class=no-num><a href="#property-index"> Property index</a>
</ul>
<!--end-toc-->
<h2 id=intro><span class=secno>1. </span> Introduction</h2>
<p><em>This section is not normative.</em>
<p>CSS Levels 1 and 2 allowed for the alignment of text via ‘<code
class=property>text-align</code>’ and the alignment of blocks by
balancing ‘<a href="#auto2"><code class=css>auto</code></a>’ margins.
However, except in table cells, vertical alignment was not possible. As
CSS3 adds further capabilities, the ability to align boxes in various
dimensions becomes more critical. This module attempts to create a
cohesive and common box alignment model to share among all of CSS.
<p class=note>The alignment of text and inline-level content is defined in
<a href="#CSS3TEXT">[CSS3TEXT]<!--{{CSS3TEXT}}--></a> and
[[CSS3LINEBOX]].
<p>Inspiration for this document:
<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 id=placement><span class=secno>1.1. </span> Module interactions</h3>
<p>This module adds some new alignment capabilities to the block layout
model described in <a href="#CSS21"
>[CSS21]<!--{{!CSS21}}--></a> chapters 9 and 10 and defines
the interaction of these properties with the alignment of table cell
content using ‘<code class=property>vertical-align</code>’, as defined
in <a href="#CSS21">[CSS21]<!--{{!CSS21}}--></a> chapter
17. The interaction of these properties with Grid Layout <a
href="#CSS3-GRID-LAYOUT"
>[CSS3-GRID-LAYOUT]<!--{{!CSS3-GRID-LAYOUT}}--></a> and
Flexible Box Layout <a href="#CSS3-FLEXBOX"
>[CSS3-FLEXBOX]<!--{{!CSS3-FLEXBOX}}--></a> is defined in
their respective modules.
<p>No properties in this module apply to the <code>::first-line</code> or
<code>::first-letter</code> pseudo-elements.
<h3 id=values><span class=secno>1.2. </span> Values</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 href="#CSS21"
>[CSS21]<!--{{!CSS21}}--></a>. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 <a
href="#CSS21">[CSS21]<!--{{!CSS21}}--></a>. Other CSS
modules may expand the definitions of these value types: for example
[[CSS3VALUES]], when combined with this module, adds the ‘<code
class=css>initial</code>’ keyword as a possible property value.
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the <a
href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h2 id=overview><span class=secno>2. </span> Overview of Alignment
Properties</h2>
<p>The alignment properties in CSS can be described along two axes:
<ul>
<li>which dimension they apply to (inline vs. stacking), and
<li>whether they control the position of the box within its parent, or the
box's content within itself.
</ul>
<p class=note>This proposal uses the terms ‘<code
class=property>justify</code>’ and ‘<code
class=property>align</code>’ to distinguish between alignment in the
inline and stacking dimensions, respectively. The choice is somewhat
arbitrary, but having the two terms allows for a consistent naming scheme
that works across all of CSS's layout models.
<p>The following table summarizes the proposed alignment properties and the
display types they can apply to.
<table class=data>
<colgroup span=1></colgroup>
<colgroup span=2></colgroup>
<colgroup span=1></colgroup>
<thead>
<tr>
<th>Common
<th>Axis
<th>Aligns
<th>Applies to
<tbody>
<tr>
<th>‘<a href="#justify-self0"><code
class=property>justify-self</code></a>’
<td>inline
<td rowspan=2><img alt="" src=self-target.jpg> element within parent
<small>(effectively adjusts margins)</small>
<td>block-level elements and grid items
<tr>
<th>‘<a href="#align-self0"><code
class=property>align-self</code></a>’
<td>stacking
<td>flex items and grid items
<tbody>
<tr>
<th>‘<a href="#justify-content0"><code
class=property>justify-content</code></a>’
<td>inline
<td rowspan=2><img alt="" src=content-target.jpg>content within element
<small>(effectively adjusts padding)</small>
<td>block containers and flex containers
<tr>
<th>‘<a href="#align-content0"><code
class=property>align-content</code></a>’
<td>stacking
<td>block containers and flex containers
<tbody>
<tr>
<th>‘<a href="#justify-items0"><code
class=property>justify-items</code></a>’
<td>inline
<td rowspan=2><img alt="" src=child-target.jpg> items inside element
<small>(controls child items’ ‘<code class=css>align/justify-self:
auto</code>’)</small>
<td>grid containers
<tr>
<th>‘<a href="#align-items0"><code
class=property>align-items</code></a>’
<td>stacking
<td>flex containers and grid containers
</table>
<p class=issue> The exact behavior of these properties on layout models
other than Flexbox is still <strong>to be determined</strong>. This is a
<strong>First Public Working Draft</strong> and is <strong>NOT
STABLE</strong>.
<p class=note> The ‘<code class=property>-items</code>’ values don't
affect the element itself. When set on a flex container or grid container,
they specify the interpretation of any ‘<code
class=css>align/justify-self: auto</code>’ used on the items in the
container element.
<p class=issue>True alignment vs. safe alignment. Maybe make safe by
default, true if ‘<a href="#true2"><code class=css>true</code></a>’ is
specified? Or safe/true depending on layout model (e.g. safe for blocks,
true for flexbox)? Current draft introduces a ‘<a href="#true2"><code
class=css>true</code></a>’ keyword, but other options should be
considered.
<h2 id=self-alignment><span class=secno>3. </span> Self-Alignment: Aligning
the Box within its Parent</h2>
<p>The ‘<a href="#justify-self0"><code
class=property>justify-self</code></a>’ and ‘<a
href="#align-self0"><code class=property>align-self</code></a>’
properties control alignment of the box within its containing block.
<div class=figure>
<p><img
alt="Diagram showing that the alignment of the element within its containing block is affected."
src=self-target.jpg>
</div>
<h3 id=justify-self><span class=secno>3.1. </span> Inline/Main-Axis
Alignment: the ‘<a href="#justify-self0"><code
class=property>justify-self</code></a>’ property</h3>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=justify-self0>justify-self</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ start | end | center ] && true?
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block-level elements 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
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per
grammar</abbr>
</table>
<p>Justifies the box within its parent along the inline/row axis: the box's
outer edges are aligned within its containing block as described below.
<dl>
<dt><dfn id=auto>‘<code class=css>auto</code>’</dfn>
<dd>For block-level elements, use alignment specified by the ‘<a
href="#justify-content0"><code
class=property>justify-content</code></a>’ property of the containing
block. For grid items, indicates that the element should stretch to fill
its slot.
<dt><dfn id=start>‘<code class=css>start</code>’</dfn>
<dd>Start-aligns the box within its containing block.
<dt><dfn id=center>‘<code class=css>center</code>’</dfn>
<dd>Centers the box within its containing block.
<dt><dfn id=end>‘<code class=css>end</code>’</dfn>
<dd>End-aligns the box within its containing block.
<dt><dfn id=true>‘<code class=css>true</code>’</dfn>
<dd>If specified, alignment is "true", and may cause the box to overflow
the start edge of the containing block. Otherwise, the box is forced to
start-align when its outer measure is wider than the containing block.
</dl>
<p>In terms of CSS2.1 block-level formatting, the rules for
"over-constrained" computations in section 10.3.3 are used only when the
element's margin box overflows the containing block <em>and</em> the ‘<a
href="#true2"><code class=css>true</code></a>’ keyword is not specified.
Otherwise those rules are ignored in favor of alignment as specified
above, and the used value of the end margin is not adjusted to correct for
the over-constraint.
<div class=example>
<p>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>
<p>For block-level elements that establish a block formatting context and
are placed next to a float, alignment is with respect to the available
space (subtracting out from the containing block measure the space taken
up by the float), not with respect to the containing block. (Note: This is
the legacy behavior of HTML <code>align</code>.)
<p class=note>This property will replace ‘<code
class=property>grid-column-align</code>’.
<h3 id=align-self><span class=secno>3.2. </span> Stacking/Cross-Axis
Alignment: the ‘<a href="#align-self0"><code
class=property>align-self</code></a>’ property</h3>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=align-self0>align-self</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ baseline | head | foot | center | stretch ] && true?
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>flex items 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
<tr>
<th>Animatable:
<td>no
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per
grammar</abbr>
</table>
<p>Aligns the box within its parent along the block/column/cross axis: the
box's outer edges are aligned within its containing block as described
below.
<dl>
<dt><dfn id=auto0>‘<code class=css>auto</code>’</dfn>
<dd>For flex items, computes to alignment specified by the ‘<a
href="#align-items0"><code class=property>align-items</code></a>’
property of the flex container. For grid items, computes to ‘<a
href="#stretch"><code class=css>stretch</code></a>’.
<dt><dfn id=baseline>‘<code class=css>baseline</code>’</dfn>
<dd>Shifts the box such that the baseline of its <i>first formatted
line</i> aligns with the corresponding baselines of other ‘<a
href="#baseline0"><code class=css>baseline</code></a>’-aligned siblings
in the same row/line.
<dt><dfn id=head>‘<code class=css>head</code>’</dfn>
<dd>Head-aligns the box within its containing block.
<dt><dfn id=foot>‘<code class=css>foot</code>’</dfn>
<dd>Foot-aligns the box within its containing block.
<dt><dfn id=center0>‘<code class=css>center</code>’</dfn>
<dd>Centers the box within its containing block.
<dt><dfn id=stretch>‘<code class=css>stretch</code>’</dfn>
<dd>Sizes the box to exactly fit its containing block.
<dt><dfn id=true0>‘<code class=css>true</code>’</dfn>
<dd>If specified, alignment is "true", and may cause the box to overflow
the head edge of the containing block. Otherwise, the box is forced to
head-align if its outer extent is longer than the containing block.
</dl>
<p>For flex items, if the "head" and "foot" are not in the alignment
dimension, the "start" and "end" sides are used instead.
<h2 id=content-alignment><span class=secno>4. </span> Content-Alignment:
Aligning the Content within the Box</h2>
<p>The ‘<a href="#justify-content0"><code
class=property>justify-content</code></a>’ and ‘<a
href="#align-content0"><code class=property>align-content</code></a>’
properties control alignment of the box's content within the box.
<div class=figure>
<p><img
alt="Diagram showing that the alignment of the content within the element is affected."
src=content-target.jpg>
</div>
<h3 id=justify-content><span class=secno>4.1. </span> Inline/Main-Axis
Alignment: the ‘<a href="#justify-content0"><code
class=property>justify-content</code></a>’ property</h3>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=justify-content0>justify-content</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ start | end | left | right | flex-start | flex-end | center
| space-between | space-around ] && true?
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block containers and flex 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
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per
grammar</abbr>
</table>
<p>Gives the default alignment of the box's content along the inline/row
axis. For block containers, this simply changes the meaning of ‘<code
class=css>justify-self: auto</code>’ on its children. For flex
containers, this aligns the contents of each flex line within its flex
line box. See [[!CSS3FLEXBOX]] for exact details.
<dl>
<dt><dfn id=auto1>‘<code class=css>auto</code>’</dfn>
<dd>If the element has ‘<code class=css>display: block</code>’ and
‘<code class=css>justify-self: auto</code>’, computes to the value
inherited from the parent. Otherwise computes to ‘<a
href="#start0"><code class=css>start</code></a>’.
<dt><dfn id=start0>‘<code class=css>start</code>’</dfn>
<dd>Start-aligns the content within its box.
<dt><dfn id=end0>‘<code class=css>end</code>’</dfn>
<dd>End-aligns the content within its box.
<dt><dfn id=flex-start>‘<code class=css>flex-start</code>’</dfn>
<dd>For flex containers, aligns the items to the main-start edge.
Otherwise equivalent to ‘<a href="#start0"><code
class=css>start</code></a>’.
<dt><dfn id=end1>‘<code class=css>end</code>’</dfn>
<dd>For flex containers, aligns the items to the main-end edge. Otherwise
equivalent to ‘<a href="#end2"><code class=css>end</code></a>’.
<dt><dfn id=left>‘<code class=css>left</code>’</dfn>
<dd>Aligns content to the line-left edge. On a flex container, this is
treated as ‘<a href="#auto2"><code class=css>auto</code></a>’ if the
line-left direction is in the wrong dimension.
<dt><dfn id=right>‘<code class=css>right</code>’</dfn>
<dd>Aligns content to the line-right edge. On a flex container, this is
treated as ‘<a href="#auto2"><code class=css>auto</code></a>’ if the
line-right direction is in the wrong dimension.
<dt><dfn id=center1>‘<code class=css>center</code>’</dfn>
<dd>Centers the content within its box
<dt><dfn id=space-between>‘<code class=css>space-between</code>’</dfn>
<dd>Distributes the content evenly throughout the line by adjusting
inter-child spacing. If there is only one child (or if the element is a
block container), this is equivalent to centering.
<dt><dfn id=space-around>‘<code class=css>space-around</code>’</dfn>
<dd>Distributes the content evenly throughout the line by adjusting
inter-child spacing and applying half of that spacing between the
first/last child and the box edges. If there is only one child (or if the
element is a block container), this is equivalent to centering.
<dt><dfn id=true1>‘<code class=css>true</code>’</dfn>
<dd>If specified, alignment is "true", and may cause the contents to
overflow the start edge of the box. Otherwise, the content is forced to
start-align if its total outer measure (before ‘<a
href="#space-between0"><code class=css>space-between</code></a>’ or
‘<a href="#space-around0"><code class=css>space-around</code></a>’ is
applied) is wider than the containing block.
</dl>
<p>For flex containers, if the "start" and "end" are not in the alignment
dimension, the "head" and "foot" sides are used instead, respectively.
<p class=note>This would, in conjunction with ‘<code
class=property>text-align</code>’, implement the HTML <code>align</code>
attribute and <code><center></code>. The weird behavior of ‘<a
href="#auto2"><code class=css>auto</code></a>’ is for that and because
‘<code class=css>display: block</code>’ elements are essentially
transparent, layout-wise, so passing through the alignment unchanged is
useful and probably intuitive to authors (though it's really weird for
implementers).
<h3 id=align-content><span class=secno>4.2. </span> Stacking/Cross-Axis
Alignment: the ‘<a href="#align-content0"><code
class=property>align-content</code></a>’ property</h3>
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=align-content0>align-content</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ head | foot | flex-start | flex-end | baseline | center |
space-between | space-around ] && true?
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block containers and flex 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
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per
grammar</abbr>
</table>
<p>Aligns the box's content within the box along the block/column/cross
axis. Values have the following meanings:
<dl>
<dt><dfn id=auto2>‘<code class=css>auto</code>’</dfn>
<dd>For block containers, equivalent to ‘<a href="#head0"><code
class=css>head</code></a>’, except that it does not cause the block to
establish a block formatting context. For table cells, defers alignment
to ‘<code class=property>vertical-align</code>’ as specified in <a
href="#CSS21">[CSS21]<!--{{!CSS21}}--></a> chapter 17.
For flex containers, it causes any positive free space to be distributed
equally across the lines. <a href="#CSS3-FLEXBOX"
>[CSS3-FLEXBOX]<!--{{!CSS3-FLEXBOX}}--></a>
<dt><dfn id=head0>‘<code class=css>head</code>’</dfn>
<dd>Head-aligns the box's content within its content box: the content is
laid out beginning at the box's head content edge.
<dt><dfn id=center2>‘<code class=css>center</code>’</dfn>
<dd>Centers the box's content within its content box: the content is
centered between the box's head and foot content edges.
<dt><dfn id=foot0>‘<code class=css>foot</code>’</dfn>
<dd>Foot-aligns the box's content within its content box: the content is
laid out so that it finishes at the foot content edge.
<dt><dfn id=flex-start0>‘<code class=css>flex-start</code>’</dfn>
<dd>For flex containers, aligns the items to the cross-start edge.
Otherwise equivalent to ‘<a href="#head0"><code
class=css>head</code></a>’.
<dt><dfn id=end2>‘<code class=css>end</code>’</dfn>
<dd>For flex containers, aligns the items to the cross-end edge. Otherwise
equivalent to ‘<a href="#foot0"><code class=css>foot</code></a>’.
<dt><dfn id=baseline0>‘<code class=css>baseline</code>’</dfn>
<dd>For table cells, grid items, and flex items, aligns this elements's
<i>first formatted line</i>'s baseline, if any, with the same
baseline in other ‘<a href="#baseline0"><code
class=css>baseline</code></a>’-aligned cells/items in the same row.
This is equivalent to the behavior of ‘<code class=css>vertical-align:
baseline</code>’ on table cells; see <a href="#CSS21"
>[CSS21]<!--{{!CSS21}}--></a> chapter 17 for details. If
size constraints prevent the baselines from fully aligning, alignment is
as close as possible. If the content's position is not fully determined
by baseline alignment, the content is head-aligned insofar as possible
while preserving the baseline alignment. (Content that has no first-line
baseline is thus also head-aligned.)
<dt><dfn id=space-between0>‘<code
class=css>space-between</code>’</dfn>
<dd>For flex containers, distributes lines evenly by adjusting inter-line
spacing. If there is only one line (or if the element is container of
line boxes), this is equivalent to centering. UAs may also apply ‘<a
href="#space-between0"><code class=css>space-between</code></a>’ to
lines in a block container.
<dt><dfn id=space-around0>‘<code class=css>space-around</code>’</dfn>
<dd>For flex containers, distributes lines evenly by adjusting inter-line
spacing and applying half of that spacing between the first/last child
and the box edges. If there is only one line (or if the element is not a
container of line boxes), this is equivalent to centering. UAs may also
apply ‘<a href="#space-between0"><code
class=css>space-between</code></a>’ to lines in a block container.
<dt><dfn id=true2>‘<code class=css>true</code>’</dfn>
<dd>If specified, alignment is "true", and may cause the content to
overflow the head edge of the containing block. Otherwise, the content is
forced to head-align if is longer than the box's content area, and will
thus overflow only the foot edge.
</dl>
<p>All values other than ‘<a href="#auto2"><code
class=css>auto</code></a>’ cause a block box to establish a block
formatting context such that its margins do not collapse with its children
and floats do not intrude into its content box.
<p>For flex containers, if the "head" and "foot" are not in the alignment
dimension, the "start" and "end" sides are used instead, respectively.
<h2 id=default-alignment><span class=secno>5. </span> Default Alignment of
Child Items</h2>
<p>The ‘<a href="#align-items0"><code
class=property>align-items</code></a>’ and ‘<a
href="#justify-items0"><code class=property>justify-items</code></a>’
properties, when set on a flex or grid container, set the default ‘<a
href="#align-self0"><code class=property>align-self</code></a>’ and
‘<a href="#justify-self0"><code
class=property>justify-self</code></a>’ behavior of the items contained
by the element.
<div class=figure>
<p><img
alt="Diagram showing that the alignment of grid items within the element is affected."
src=child-target.jpg>
</div>
<h3 id=justify-items><span class=secno>5.1. </span> Inline/Main-Axis
Alignment: the ‘<a href="#justify-items0"><code
class=property>justify-items</code></a>’ property</h3>
<p class=issue>This could be applied to grid elements and set the default
alignment of the grid items. It mainly exists because Flexbox wants ‘<a
href="#align-items0"><code class=property>align-items</code></a>’; see
below.
<table class=propdef>
<tbody>
<tr>
<th>Name:
<td><dfn id=justify-items0>justify-items</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ start | center | end ] && true?
<tr>
<th>Initial:
<td>auto