forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.src.html
More file actions
executable file
·971 lines (815 loc) · 37.4 KB
/
Overview.src.html
File metadata and controls
executable file
·971 lines (815 loc) · 37.4 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS Box Alignment Module Level 3</title>
<link rel=contents href="#contents">
<link rel=index href="#index">
<link rel="stylesheet" type="text/css" href="../default.css">
<link href="../csslogo.ico" rel="shortcut icon" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
<style type="text/css">
.issue th:first-child { text-align: left !important; }
[rowspan] > img { max-height: 4em; float: right; }
[rowspan] { vertical-align: middle; }
small { display: block; }
</style>
</head>
<div class="head">
<!--logo-->
<h1>CSS Box Alignment Module Level 3</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:
<!--<dd><a href="[VERSION]">http://www.w3.org/TR/[YEAR]/WD-[SHORTNAME]-[CDATE]/</a>-->
<dd>ED-[SHORTNAME]-[CDATE]
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css3-align/">http://www.w3.org/TR/[SHORTNAME]/</a>
<dt>Editor's draft:
<dd><a href="http://dev.w3.org/csswg/[SHORTNAME]/">http://dev.w3.org/csswg/[SHORTNAME]/</a>
<dt>Previous 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>Issue Tracking:</dt>
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/39">http://www.w3.org/Style/CSS/Tracker/products/39</a>
<dt>Feedback:</dt>
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-align%5D%20feedback"
>www-style@w3.org</a>
with subject line “<kbd>[css-align]
<var>… message topic …</var></kbd>”
(<a rel="discussion" href="http://lists.w3.org/Archives/Public/www-style/"
>archives</a>)
<dt>Editors:
<dd class="h-card vcard">
<a class="p-name fn u-url url" rel="author"
href="http://fantasai.inkedblade.net/contact">Elika J. Etemad</a>,
<span class="p-org org">Mozilla</span>
</dl>
<!--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 [[CSS3TEXT]]
and [[CSS3LINE]].)
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>
<!--status-->
<p>The following features are at risk: …
<h2 class="no-num no-toc" id="contents">
Table of contents</h2>
<!--toc-->
<h2 id="intro">
Introduction</h2>
<p><em>This section is not normative.</em>
<p>CSS Levels 1 and 2 allowed for the alignment of text via 'text-align' and
the alignment of blocks by balancing ''auto'' 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 [[CSS3TEXT]]
and [[CSS3LINE]].
<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">
Module interactions</h3>
<p>This module adds some new alignment capabilities to the block layout
model described in [[!CSS21]] chapters 9 and 10 and defines the interaction
of these properties with the alignment of table cell content using
'vertical-align', as defined in [[!CSS21]] chapter 17.
The interaction of these properties with
Grid Layout [[!CSS3-GRID-LAYOUT]]
and Flexible Box Layout [[!CSS3-FLEXBOX]]
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">
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 [[!CSS21]]. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
Other CSS modules may expand the definitions of these value types: for
example [[CSS3VAL]], when combined with this module, adds the
''initial'' 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">
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 'justify' and 'align' to distinguish
between alignment in the inline and stacking dimensions, respectively.
The choice is somewhat arbitrary, but having the two terms allows for
a consistent naming scheme that works across all of CSS's layout models.
<p>The following table summarizes the proposed alignment properties
and the display types they can apply to.
<table class=data>
<colgroup span=1></colgroup>
<colgroup span=2></colgroup>
<colgroup span=1></colgroup>
<thead>
<tr><th>Common
<th>Axis
<th>Aligns
<th>Applies to
</thead>
<tbody>
<tr><th>'justify-self'
<td>inline
<td rowspan=2><img src="self-target.jpg" alt=""> element within parent <small>(effectively adjusts margins)</small>
<td>block-level elements and grid items
<tr><th>'align-self'
<td>stacking
<td>flex items and grid items
</tbody>
<tbody>
<tr><th>'justify-content'
<td>inline
<td rowspan=2><img src="content-target.jpg" alt="">content within element <small>(effectively adjusts padding)</small>
<td>block containers and flex containers
<tr><th>'align-content'
<td>stacking
<td>block containers and flex containers
</tbody>
<tbody>
<tr><th>'justify-items'
<td>inline
<td rowspan=2><img src="child-target.jpg" alt=""> items inside element <small>(controls child items’ ''align/justify-self: auto'')</small>
<td>grid containers
<tr><th>'align-items'
<td>stacking
<td>flex containers and grid containers
</tbody>
</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 '-items' values don't affect the element itself.
When set on a flex container or grid container,
they specify the interpretation of any ''align/justify-self: auto'' used on the items in the container element.
<p class=issue>True alignment vs. safe alignment.
Maybe make safe by default, true if ''true'' is specified?
Or safe/true depending on layout model (e.g. safe for blocks, true for flexbox)?
Current draft introduces a ''true'' keyword, but other options should be considered.
<h2 id='alignment-values'>
Alignment Values</h2>
<p>All of the alignment properties use a common set of values,
defined below.
<dl>
<dt><dfn>alignment subject</dfn>
<dd>
The <i>alignment subject</i> is the thing or things being aligned by the property.
For 'justify-self' and 'align-self',
the <i>alignment subject</i> is the margin box of the box the property is set on.
For 'justify-content' and 'align-content',
the <i>alignment subject</i> is defined by the layout mode.
<dt><dfn>alignment container</dfn>
<dd>
The <i>alignment container</i> is the rectangle that the <i>alignment subject</i> is aligned within.
This is defined by the layout mode,
but is usually the <i>alignment subject</i>’s containing block.
</dl>
<h3 id='positional-values'>
Positional Alignment: the ''center'', ''start'', ''end'', ''self-start'', ''self-end'', ''flex-start'', ''flex-end'', ''left'', and ''right'' keywords</h3>
<p>...
<pre class='prod'>
<dfn><item-position></dfn> = center | stretch | start | end | self-start | self-end |
flex-start | flex-end | left | right;
<dfn><content-position></dfn> = center | start | end | flex-start | flex-end | left | right;</pre>
<dl>
<dt><dfn>''center''</dfn>
<dd>Centers the <i>alignment subject</i> within its <i>alignment container</i>.
<dt><dfn>''stretch''</dfn>
<dd>If the 'width' or 'height' (as appropriate) of the <i>alignment subject</i> is ''auto'',
its used value is the length necessary to make the <i>alignment subject</i>’s outer size
as close to the size of the <i>alignment container</i> as possible,
while still respecting the constraints imposed by 'min/max-width/height'.
Otherwise, this is equivalent to ''start''.
<dt><dfn>''start''</dfn>
<dd>Aligns the <i>alignment subject</i> to be flush with the <i>alignment container</i>’s start edge.
<dt><dfn>''end''</dfn>
<dd>Aligns the <i>alignment subject</i> to be flush with the <i>alignment container</i>’s end edge.
<dt><dfn>''self-start''</dfn>
<dd>Aligns the <i>alignment subject</i> to be flush with the edge of the <i>alignment container</i>
corresponding to the <i>alignment subject</i>’s start side.
<dt><dfn>''self-end''</dfn>
<dd>Aligns the <i>alignment subject</i> to be flush with the edge of the <i>alignment container</i>
corresponding to the <i>alignment subject</i>’s end side.
<dt><dfn>''flex-start''</dfn>
<dd><strong>Only used in flex layout.</strong> [[!CSS3-FLEXBOX]]
Aligns the <i>alignment subject</i> to be flush with the edge of the <i>alignment container</i>
corresponding to the <i>flex container</i>’s main-start or cross-start side, as appropriate.
When used in layout modes other than Flexbox,
this is equivalent to ''start''.
<dt><dfn>''flex-end''</dfn>
<dd><strong>Only used in flex layout.</strong>
Aligns the <i>alignment subject</i> to be flush with the edge of the <i>alignment container</i>
corresponding to the <i>flex container</i>’s main-end or cross-end side, as appropriate.
When used in layout modes other than Flexbox,
this is equivalent to ''start''.
<dt><dfn>''left''</dfn>
<dd>Aligns the <i>alignment subject</i> to be flush with the <i>alignment container</i>’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 is equivalent to ''start''.
<dt><dfn>''right''</dfn>
<dd>Aligns the <i>alignment subject</i> to be flush with the <i>alignment container</i>’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 is equivalent to ''start''.
</dl>
<p class='issue'>Add example images.
<h3 id='baseline'>
Baseline Alignment: the ''baseline'' keyword</h3>
<p>...
<dl>
<dt><dfn>''baseline''</dfn>
<dd>For table cells, grid items, and flex items, aligns the
cell/item's <i>first formatted line</i>'s baseline, if any,
with the same baseline in other ''baseline''-aligned cells/items in the row/column (as appropriate for the axis).
This is similar to the behavior of ''vertical-align: baseline'' on table cells;
see [[!CSS21]] chapter 17 for details.
If the content's position is not fully determined by baseline alignment,
the content is start-aligned insofar as possible while preserving the baseline alignment.
(Content that has no first-line baseline is thus also start-aligned.)
</dl>
<p class='issue'>Add example images.
<h3 id='distribution-values'>
Distributed Alignment: the ''space-between'', ''space-around'', and ''space-evenly'' keywords</h3>
<p>The distribution values are used by 'justify-content' and 'align-content'
to distribute the items in the <i>alignment subject</i>
evenly between the start and end edges of the <i>alignment container</i>.
<pre class='prod'>
<dfn><content-distribution></dfn> = space-between | space-around | space-evenly | stretch</pre>
<dl>
<dt><dfn>''space-between''</dfn>
<dd>The items are evenly distributed in the <i>alignment container</i>.
The first item is placed flush with the start edge of the <i>alignment container</i>,
the last item is placed flush with the end edge of the <i>alignment container</i>,
and the remaining items are distributed so that the spacing between any two adjacent items is the same.
Unless otherwise specified,
this value falls back to ''start''.
<dt><dfn>''space-around''</dfn>
<dd>The items are evenly distributed in the <i>alignment container</i>,
with a half-size space on either end.
The items are distributed so that the spacing between any two adjacent items is the same,
and the spacing before the first and after the last item is half the size of the other spacing.
Unless otherwise specified,
this value falls back to ''center''.
<dt><dfn>''space-evenly''</dfn>
<dd>The items are evenly distributed in the <i>alignment container</i>,
with a full-size space on either end.
The items are distributed so that the spacing between any two adjacent items,
before the first item,
and after the last item
is the same.
Unless otherwise specified,
this value falls back to ''center''.
<dt><dfn>''stretch''</dfn>
<dd>If the combined size of the items is less than the size of the <i>alignment container</i>,
any ''auto''-sized items have their size increased equally so that the combined size exactly fills the <i>alignment container</i>.
Otherwise,
or if there are no ''auto''-sized items,
this value is identical to ''flex-start''.
<span class='note'>(For layout modes other than flex layout, ''flex-start'' is identical to ''start''.)</span>
</dl>
<p class='issue'>Add example images.
<h3 id='overflow-values'>
Overflow Alignment: the ''safe'' and ''true'' keywords</h3>
<p>When the <i>alignment subject</i> is larger than the <i>alignment container</i>,
it will overflow.
Some alignment modes, if honored in this situation,
may cause data loss:
for example, if the contents of a sidebar are centered,
when they overflow they may send part of their boxes past the viewport's start edge,
which can't be scrolled to.
<p>To help combat this problem,
the overflow behavior of an element's alignment mode can be explicitly specified.
"True" alignment honors the alignment mode, even if it causes data loss,
while "safe" alignment adjusts the alignment mode in an attempt to avoid data loss.
<p>If the overflow alignment isn't explicitly specified,
the default overflow alignment is determined by the layout mode.
Document-centric layout modes, such as block layout, default to "safe" overflow alignment,
while design-centric layout modes, such as flex layout, default to "true" overflow alignment.
<pre class='prod'>
<dfn><overflow-position></dfn> = true | safe</pre>
<dl>
<dt><dfn>''safe''</dfn>
<dd>If the size of the <i>alignment subject</i> overflows the <i>alignment container</i>,
the <i>alignment subject</i> is instead aligned as if the alignment mode were ''start''.
<dt><dfn>''true''</dfn>
<dd>Regardless of the relative sizes of the <i>alignment subject</i> and <i>alignment container</i>,
the given alignment value is honored.
</dl>
<p class='issue'>Transplant example 10 from flexbox.
<h2 id='content-distribution'>
Content Distribution: the 'justify-content' and 'align-content' properties</h2>
<table class=propdef>
<tr>
<th>Name:
<td><dfn>justify-content</dfn>, <dfn>align-content</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ <var><content-distribution></var> <var><content-position></var>? | <var><content-position></var> ] && <var><overflow-position></var>?
<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
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per grammar</abbr>
</table>
<p>
Aligns the contents of the box as a whole along the box's inline/row/main axis.
Values other than ''auto'' are <a href="#alignment-values">defined above</a>.
<dl>
<dt>Block Layout:
<dd>
<p>All values other than ''auto'' force the block container to establish a new formatting context.
''auto'' otherwise behaves as ''start''.
<p>The <i>alignment container</i> is the <i>block container</i>’s content box.
The <i>alignment subject</i> is the entire contents of the block.
<p>The 'align-content' property applies along the <i>block axis</i>,
but the <var><content-distribution></var> values behave as their fallback values.
The 'justify-content' property does not apply to and has no effect on block containers.
<dt>Multicol Layout:
<dd>
<p>''auto'' behaves as ''start''.
<p>The <i>alignment container</i> is the <i>multi-column element</i>’s content box.
The <i>alignment subject</i> is the column boxes, as a unit.
<p>The 'align-content' property applies along the <i>block axis</i>,
but the <var><content-distribution></var> values behave as their fallback values.
The 'justify-content' property does not apply to and has no effect on multi-column elements.
<dt>Flex Layout:
<dd>
<p>''auto'' computes to ''stretch''.
<p>The <i>alignment container</i> is the <i>flex container</i>’s content box.
For 'justify-content', the <i>alignment subject</i> is the <i>flex items</i> in each <i>flex line</i>;
for 'align-content', the <i>alignment subject</i> is the <i>flex lines</i>.
<p>The 'align-content' property applies along the <i>cross axis</i>.
The 'justify-content' property applies along the <i>main axis</i>,
but ''stretch'' behaves as ''start''.
<p>See [[!CSS3-FLEXBOX]] for details.
<dt>Grid Layout:
<dd>
<p>''auto'' computes to ''stretch''.
<p>The <i>alignment container</i> is the <i>grid container</i>’s content box.
The <i>alignment subject</i> is the bounds of the <i>grid</i>.
<span class='issue'>Need to dfn a better term for this in Grid.</span>
<p>The 'align-content' property applies along the <i>block (column) axis</i>.
The 'justify-content' property applies along the <i>inline (row) axis</i>.
In both properties, the <var><content-distribution></var> values behave as their fallback values.
</dl>
<h2 id="self-alignment">
Self-Alignment: Aligning the Box within its Parent</h2>
<p>The 'justify-self' and 'align-self' properties control alignment
of the box within its containing block.
<div class=figure>
<p><img src=self-target.jpg
alt="Diagram showing that the alignment of the element within its containing block is affected.">
</div>
<h3 id="justify-self">
Inline/Main-Axis Alignment: the 'justify-self' property</h3>
<table class=propdef>
<tr>
<th>Name:
<td><dfn>justify-self</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ baseline | start | end | center | stretch ] && 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>''auto''</dfn></dt>
<dd>For block-level elements, use alignment specified by the 'justify-content'
property of the containing block.
For grid items, indicates that the element should stretch to fill its slot.
<dt><dfn>''baseline''</dfn></dt>
<dd>Shifts the box such that the baseline of its <i>first formatted line</i>
aligns with the corresponding baselines of other ''baseline''-aligned siblings in the same column.
<p class="issue">Define alignment of first lines with opposite writing modes.
<dt><dfn>''start''</dfn></dt>
<dd>Start-aligns the box within its containing block.
<dt><dfn>''center''</dfn></dt>
<dd>Centers the box within its containing block.
<dt><dfn>''end''</dfn></dt>
<dd>End-aligns the box within its containing block.
<dt><dfn>''stretch''</dfn></dt>
<dd>Sizes the box to exactly fit its containing block.
<dt><dfn>''true''</dfn></dt>
<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 ''true'' 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 'grid-column-align'.
<h3 id="align-self">
Stacking/Cross-Axis Alignment: the 'align-self' property</h3>
<table class=propdef>
<tr>
<th>Name:
<td><dfn>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>''auto''</dfn></dt>
<dd>For flex items, computes to alignment specified by the 'align-items'
property of the flex container.
For grid items, computes to ''stretch''.
<dt><dfn>''baseline''</dfn></dt>
<dd>Shifts the box such that the baseline of its <i>first formatted line</i>
aligns with the corresponding baselines of other ''baseline''-aligned siblings in the same row/line.
<dt><dfn>''head''</dfn></dt>
<dd>Head-aligns the box within its containing block.
<dt><dfn>''foot''</dfn></dt>
<dd>Foot-aligns the box within its containing block.
<dt><dfn>''center''</dfn></dt>
<dd>Centers the box within its containing block.
<dt><dfn>''stretch''</dfn></dt>
<dd>Sizes the box to exactly fit its containing block.
<dt><dfn>''true''</dfn></dt>
<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="default-alignment">
Default Alignment of Child Items</h2>
<p>The 'align-items' and 'justify-items' properties, when set on a
flex or grid container, set the default 'align-self' and 'justify-self'
behavior of the items contained by the element.
<div class=figure>
<p><img src=child-target.jpg
alt="Diagram showing that the alignment of grid items within the element is affected.">
</div>
<h3 id="justify-items">
Inline/Main-Axis Alignment: the 'justify-items' 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 'align-items'; see below.
<table class=propdef>
<tr>
<th>Name:
<td><dfn>justify-items</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ start | center | end ] && true?
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>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
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per grammar</abbr>
</table>
Gives the default alignment of the box's content along the inline/row axis.
For block containers, this simply changes the meaning of ''justify-self: auto'' on its children.
For flex containers, this aligns the contents of each flex line within its flex line box.
See [[!CSS3-FLEXBOX]] for exact details.
<p class=note>This would, in conjunction with 'text-align', implement the HTML <code>align</code> attribute and <code><center></code>.
The weird behavior of ''auto'' is for that and because ''display: block'' 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-items">
Stacking/Cross-Axis Alignment: the 'align-items' property</h3>
<table class=propdef>
<tr>
<th>Name:
<td><dfn>align-items</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>auto | [ head | foot | flex-start | flex-end | center | baseline | stretch ] && true?
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>flexbox 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
<tr>
<th>Canonical order:
<td><abbr title="follows order of property value definition">per grammar</abbr>
</table>
<p>Sets the default 'align-self' of the flex container's children or the
grid container's items.
The ''auto'' value computes to ''stretch'' on flex and grid containers.
<h2 id="conformance">
Conformance</h2>
<h3 id="conventions">
Document conventions</h3>
<p>Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words “MUST”,
“MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
“RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
<p>All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
<p>Examples in this specification are introduced with the words “for example”
or are set apart from the normative text with <code>class="example"</code>,
like this:
<div class="example">
<p>This is an example of an informative example.</p>
</div>
<p>Informative notes begin with the word “Note” and are set apart from the
normative text with <code>class="note"</code>, like this:
<p class="note">Note, this is an informative note.</p>
<h3 id="conformance-classes">
Conformance classes</h3>
<p>Conformance to CSS Box Alignment Module Level 3
is defined for three conformance classes:
<dl>
<dt><dfn title="style sheet!!as conformance class">style sheet</dfn>
<dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#style-sheet">CSS
style sheet</a>.
<dt><dfn>renderer</dfn></dt>
<dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
that interprets the semantics of a style sheet and renders
documents that use them.
<dt><dfn id="authoring-tool">authoring tool</dfn></dt>
<dd>A <a href="http://www.w3.org/TR/CSS21/conform.html#user-agent">UA</a>
that writes a style sheet.
</dl>
<p>A style sheet is conformant to CSS Box Alignment Module Level 3
if all of its statements that use syntax defined in this module are valid
according to the generic CSS grammar and the individual grammars of each
feature defined in this module.
<p>A renderer is conformant to CSS Box Alignment Module Level 3
if, in addition to interpreting the style sheet as defined by the
appropriate specifications, it supports all the features defined
by CSS Box Alignment Module Level 3 by parsing them correctly
and rendering the document accordingly. However, the inability of a
UA to correctly render a document due to limitations of the device
does not make the UA non-conformant. (For example, a UA is not
required to render color on a monochrome monitor.)
<p>An authoring tool is conformant to CSS Box Alignment Module Level 3
if it writes style sheets that are syntactically correct according to the
generic CSS grammar and the individual grammars of each feature in
this module, and meet all other conformance requirements of style sheets
as described in this module.
<h3 id="partial">
Partial implementations</h3>
<p>So that authors can exploit the forward-compatible parsing rules to
assign fallback values, CSS renderers <strong>must</strong>
treat as invalid (and <a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignore
as appropriate</a>) any at-rules, properties, property values, keywords,
and other syntactic constructs for which they have no usable level of
support. In particular, user agents <strong>must not</strong> selectively
ignore unsupported component values and honor supported values in a single
multi-value property declaration: if any value is considered invalid
(as unsupported values must be), CSS requires that the entire declaration
be ignored.</p>
<h3 id="experimental">
Experimental implementations</h3>
<p>To avoid clashes with future CSS features, the CSS2.1 specification
reserves a <a href="http://www.w3.org/TR/CSS21/syndata.html#vendor-keywords">prefixed
syntax</a> for proprietary and experimental extensions to CSS.
<p>Prior to a specification reaching the Candidate Recommendation stage
in the W3C process, all implementations of a CSS feature are considered
experimental. The CSS Working Group recommends that implementations
use a vendor-prefixed syntax for such features, including those in
W3C Working Drafts. This avoids incompatibilities with future changes
in the draft.
</p>
<h3 id="testing">
Non-experimental implementations</h3>
<p>Once a specification reaches the Candidate Recommendation stage,
non-experimental implementations are possible, and implementors should
release an unprefixed implementation of any CR-level feature they
can demonstrate to be correctly implemented according to spec.
<p>To establish and maintain the interoperability of CSS across
implementations, the CSS Working Group requests that non-experimental
CSS renderers submit an implementation report (and, if necessary, the
testcases used for that implementation report) to the W3C before
releasing an unprefixed implementation of any CSS features. Testcases
submitted to W3C are subject to review and correction by the CSS
Working Group.
<p>Further information on submitting testcases and implementation reports
can be found from on the CSS Working Group's website at
<a href="http://www.w3.org/Style/CSS/Test/">http://www.w3.org/Style/CSS/Test/</a>.
Questions should be directed to the
<a href="http://lists.w3.org/Archives/Public/public-css-testsuite">public-css-testsuite@w3.org</a>
mailing list.
<h3 id="cr-exit-criteria">
CR exit criteria</h3>
<p class=issue>[Change or remove the following CR exit criteria if
the spec is not a module, but, e.g., a Note or a profile. This text was <a
href="http://www.w3.org/Style/CSS/Tracker/actions/44"> decided on 2008-06-04.</a>]</p>
<p>
For this specification to be advanced to Proposed Recommendation,
there must be at least two independent, interoperable implementations
of each feature. Each feature may be implemented by a different set of
products, there is no requirement that all features be implemented by
a single product. For the purposes of this criterion, we define the
following terms:
<dl>
<dt>independent <dd>each implementation must be developed by a
different party and cannot share, reuse, or derive from code
used by another qualifying implementation. Sections of code that
have no bearing on the implementation of this specification are
exempt from this requirement.
<dt>interoperable <dd>passing the respective test case(s) in the
official CSS test suite, or, if the implementation is not a Web
browser, an equivalent test. Every relevant test in the test
suite should have an equivalent test created if such a user
agent (UA) is to be used to claim interoperability. In addition
if such a UA is to be used to claim interoperability, then there
must one or more additional UAs which can also pass those
equivalent tests in the same way for the purpose of
interoperability. The equivalent tests must be made publicly
available for the purposes of peer review.
<dt>implementation <dd>a user agent which:
<ol class=inline>
<li>implements the specification.
<li>is available to the general public. The implementation may
be a shipping product or other publicly available version
(i.e., beta version, preview release, or “nightly build”).
Non-shipping product releases must have implemented the
feature(s) for a period of at least one month in order to
demonstrate stability.
<li>is not experimental (i.e., a version specifically designed
to pass the test suite and is not intended for normal usage
going forward).
</ol>
</dl>
<p>The specification will remain Candidate Recommendation for at least
six months.
<h2 class=no-num id="acknowledgments">
Acknowledgments</h2>
<p>Special thanks goes to Markus Mielke, Alex Mogilevsky, and the
participants in the CSSWG's March 2008 F2F alignment discussions.
<h2 class=no-num id="references">
References</h2>
<h3 class="no-num" id="normative-references">
Normative references</h3>
<!--normative-->
<h3 class="no-num" id="other-references">
Other references</h3>
<!--informative-->
<h2 class="no-num" id="index">
Index</h2>
<!--index-->
<h2 class="no-num" id="property-index">
Property index</h2>
<!-- properties -->
</body>
</html>
<!-- Keep this comment at the end of the file
Local variables:
mode: html
sgml-declaration:"~/SGML/html5.decl"
sgml-default-doctype-name:"html"
sgml-minimize-attributes:t
sgml-nofill-elements:("pre" "style" "br")
sgml-live-element-indicator:t
sgml-omittag:nil
sgml-shorttag:nil
sgml-namecase-general:t
sgml-general-insert-case:lower
sgml-always-quote-attributes:t
sgml-indent-step:nil
sgml-indent-data:t
sgml-parent-document:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->