-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.html
3501 lines (2897 loc) · 266 KB
/
Overview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang=en><head>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>CSS Grid Layout Module Level 1</title>
<link href=../default.css rel=stylesheet type=text/css>
<link href=../csslogo.ico rel="shortcut icon" type=image/x-icon>
<style>
body {
background: url("https://www.w3.org/StyleSheets/TR/logo-ED") top left no-repeat white;
background-attachment: fixed;
color: black;
font-family: sans-serif;
margin: 0 auto;
max-width: 50em;
padding: 2em 1em 2em 70px;
}
:link { color: #00C; background: transparent }
:visited { color: #609; background: transparent }
a[href]:active { color: #C00; background: transparent }
a[href]:hover { background: #ffa }
a[href] img { border-style: none }
h1, h2, h3, h4, h5, h6 { text-align: left }
h1, h2, h3 { color: #005A9C; }
h1 { font: 170% sans-serif }
h2 { font: 140% sans-serif }
h3 { font: 120% sans-serif }
h4 { font: bold 100% sans-serif }
h5 { font: italic 100% sans-serif }
h6 { font: small-caps 100% sans-serif }
.hide { display: none }
div.head { margin-bottom: 1em }
div.head h1 { margin-top: 2em; clear: both }
div.head table { margin-left: 2em; margin-top: 2em }
p.copyright { font-size: small }
p.copyright small { font-size: small }
pre { margin-left: 2em }
dt { font-weight: bold }
ul.toc, ol.toc {
list-style: none;
}
</style>
<style type=text/css>
.example {
clear:both
}
.pseudo-code {
font-family:monospace
}
.pseudo-code > ol {
list-style-type:decimal
}
.pseudo-code > ol > li > ol {
list-style-type:lower-latin
}
.pseudo-code > ol > li > ol > li > ol {
list-style-type:lower-roman
}
.pseudo-code ul {
list-style-type:disc
}
dd > p:nth-child(1) {
margin-top:0
}
dd:last-child {
margin-bottom: 0;
}
dl.phase {
padding-left: .5em;
border-left: .5em #e0e0e0 solid;
}
</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 Grid Layout Module Level 1</h1>
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20140707>7 July 2014</span></span></span></h2>
<div data-fill-with=spec-metadata><dl>
<dt>This version:
<dd><a class=u-url href=http://dev.w3.org/csswg/css-grid/>http://dev.w3.org/csswg/css-grid/</a>
<dt>Latest version:
<dd><a href=http://www.w3.org/TR/css-grid-1/>http://www.w3.org/TR/css-grid-1/</a>
<dt>Previous Versions:
<dd><dd><a href=http://www.w3.org/TR/2014/WD-css-grid-1-20140513/ rel=previous>http://www.w3.org/TR/2014/WD-css-grid-1-20140513/</a>
<dd><dd><a href=http://www.w3.org/TR/2014/WD-css-grid-1-20140123/ rel=previous>http://www.w3.org/TR/2014/WD-css-grid-1-20140123/</a>
<dd><dd><a href=http://www.w3.org/TR/2013/WD-css3-grid-layout-20130402/ rel=previous>http://www.w3.org/TR/2013/WD-css3-grid-layout-20130402/</a>
<dd><dd><a href=http://www.w3.org/TR/2012/WD-css3-grid-layout-20121106/ rel=previous>http://www.w3.org/TR/2012/WD-css3-grid-layout-20121106/</a>
<dt>Feedback:
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-grid%5D%20feedback">www-style@w3.org</a>
with subject line
“<kbd>[css-grid] <var>… message topic …</var></kbd>”(<a href=http://lists.w3.org/Archives/Public/www-style/ rel=discussion>archives</a>)
<dt>Editors:
<dd><dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://www.xanthir.com/contact/>Tab Atkins Jr.</a> (<span class="p-org org">Google</span>)
<dd><dd class="p-author h-card vcard"><a class="p-name fn u-url url" href=http://fantasai.inkedblade.net/contact>fantasai</a> (<span class="p-org org">Mozilla</span>)
<dd><dd class="p-author h-card vcard"><a class="p-name fn u-email email" href=mailto:ratan@microsoft.com>Rossen Atanassov</a> (<span class="p-org org">Microsoft</span>)
<dt>Former Editors:
<dd><dd class="p-author h-card vcard"><a class="p-name fn u-email email" href=mailto:alexmog@microsoft.com>Alex Mogilevsky</a> (<span class="p-org org">Microsoft Corporation</span>)
<dd><dd class="p-author h-card vcard"><a class="p-name fn u-email email" href=mailto:pcupp@microsoft.com>Phil Cupp</a> (<span class="p-org org">Microsoft Corporation</span>)
<dt>Issues list:
<dd><a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=CSS&component=Grid+Layout&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED">In Bugzilla</a>
</dl>
</div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 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>), All Rights Reserved. W3C <a href=http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer>liability</a>, <a href=http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks>trademark</a> and <a href=http://www.w3.org/Consortium/Legal/copyright-documents>document use</a> rules apply.
</p>
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc no-ref heading settled heading" id=abstract><span class=content>Abstract</span></h2>
<div class=p-summary data-fill-with=abstract><p>This CSS module defines a two-dimensional grid-based layout system, optimized for user interface design. In the grid layout model, the children of a grid container can be positioned into arbitrary slots in a flexible or fixed predefined layout grid.</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 heading" id=status><span class=content>Status of this document</span></h2>
<div data-fill-with=status><p>
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
<p>
The (<a href=http://lists.w3.org/Archives/Public/www-style/>archived</a>) public mailing list
<a href="mailto:www-style@w3.org?Subject=%5Bcss-grid%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-grid” in the subject,
preferably like this:
“[css-grid] <em>…summary of comment…</em>”
<p>
This document was produced by the <a href=http://www.w3.org/Style/CSS/members>CSS Working Group</a>
(part of the <a href=http://www.w3.org/Style/>Style Activity</a>).
<p>
This document was produced by a group operating under
the <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/>5 February 2004 W3C Patent Policy</a>.
W3C maintains a <a href=http://www.w3.org/2004/01/pp-impl/32061/status rel=disclosure>public list of any patent disclosures</a>
made in connection with the deliverables of the group;
that page also includes instructions for disclosing a patent.
An individual who has actual knowledge of a patent which the individual believes contains <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential>Essential Claim(s)</a>
must disclose the information in accordance with <a href=http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure>section 6 of the W3C Patent Policy</a>.</div>
<div data-fill-with=at-risk><p>The following features are at-risk, and may be dropped during the CR period:
<ul><li>the <a class=css data-link-for=grid-template-rows data-link-type=maybe href=#valuedef-subgrid0 title=subgrid>subgrid</a> value of <a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a> and <a class=property data-link-type=propdesc href=#propdef-grid-template-rows title=grid-template-rows>grid-template-rows</a>, and its component parts individually</ul></div>
<h2 class="no-num no-toc no-ref heading settled heading" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents><ul class=toc>
<li><a href=#intro><span class=secno>1</span> Introduction and Overview</a>
<ul class=toc>
<li><a href=#background><span class=secno>1.1</span> Background and Motivation</a>
<li><a href=#adapting-to-available-space><span class=secno>1.2</span> Adapting Layouts to Available Space</a>
<li><a href=#source-independence><span class=secno>1.3</span> Source Independence</a>
<li><a href=#grid-layering><span class=secno>1.4</span> Grid Layering of Elements</a></ul>
<li><a href=#grid-concepts><span class=secno>2</span> Grid Layout Concepts and Terminology</a>
<ul class=toc>
<li><a href=#grid-track-concept><span class=secno>2.1</span> Grid Tracks and Cells</a>
<li><a href=#grid-line-concept><span class=secno>2.2</span> Grid Lines</a>
<li><a href=#grid-area-concept><span class=secno>2.3</span> Grid Areas</a></ul>
<li><a href=#grid-model><span class=secno>3</span> Grid Containers</a>
<ul class=toc>
<li><a href=#grid-containers><span class=secno>3.1</span> Establishing Grid Containers: the <span class=css data-link-for=display data-link-type=maybe title=grid>grid</span> and <span class=css data-link-type=maybe title=inline-grid>inline-grid</span> <span class=property data-link-type=propdesc title=display>display</span> values</a>
<li><a href=#intrinsic-sizes><span class=secno>3.2</span> Sizing Grid Containers</a></ul>
<li><a href=#grid-items><span class=secno>4</span> Grid Items</a>
<ul class=toc>
<li><a href=#visibility-collapse><span class=secno>4.1</span> Collapsed Grid Items: the <span class=property data-link-type=propdesc title=visibility>visibility</span> property</a>
<li><a href=#order-property><span class=secno>4.2</span> Reordered Grid Items: the <span class=property data-link-type=propdesc title=order>order</span> property</a>
<li><a href=#static-position><span class=secno>4.3</span> Static Position of Grid Container Children</a></ul>
<li><a href=#grid-definition><span class=secno>5</span> The Explicit Grid</a>
<ul class=toc>
<li><a href=#track-sizing><span class=secno>5.1</span> Track Sizing: the <span class=property data-link-type=propdesc title=grid-template-rows>grid-template-rows</span> and <span class=property data-link-type=propdesc title=grid-template-columns>grid-template-columns</span> properties</a>
<ul class=toc>
<li><a href=#named-lines><span class=secno>5.1.1</span> Named Grid Lines: the ''(<span class=production data-link-type=type title="<custom-ident>"><custom-ident></span>*)'' syntax</a>
<li><a href=#repeat-notation><span class=secno>5.1.2</span> Repeating Rows and Columns: the <span class=css data-link-type=maybe title=repeat()>repeat()</span> notation</a>
<li><a href=#fr-unit><span class=secno>5.1.3</span> Flexible Lengths: the <span class=css data-link-type=maybe title=fr>fr</span> unit</a>
<li><a href=#subgrids><span class=secno>5.1.4</span> Subgrids: the <span class=css data-link-for=grid-template-rows data-link-type=maybe title=subgrid>subgrid</span> keyword</a>
<li><a href=#resolved-track-list><span class=secno>5.1.5</span> Resolved Values</a></ul>
<li><a href=#grid-template-areas-property><span class=secno>5.2</span> Named Areas: the <span class=property data-link-type=propdesc title=grid-template-areas>grid-template-areas</span> property</a>
<ul class=toc>
<li><a href=#implicit-named-lines><span class=secno>5.2.1</span> Implicit Named Lines</a>
<li><a href=#implicit-named-areas><span class=secno>5.2.2</span> Implicit Named Areas</a></ul>
<li><a href=#explicit-grid-shorthand><span class=secno>5.3</span> Explicit Grid Shorthand: the <span class=property data-link-type=propdesc title=grid-template>grid-template</span> property</a></ul>
<li><a href=#implicit-grids><span class=secno>6</span> The Implicit Grid</a>
<ul class=toc>
<li><a href=#auto-tracks><span class=secno>6.1</span> Sizing Auto-generated Rows and Columns: the <span class=property data-link-type=propdesc title=grid-auto-rows>grid-auto-rows</span> and <span class=property data-link-type=propdesc title=grid-auto-columns>grid-auto-columns</span> properties</a>
<li><a href=#grid-auto-flow-property><span class=secno>6.2</span> <span data-dfn-type=dfn data-noexport="" title="auto-placement|automatic placement">Automatic Placement</span>: the <span class=property data-link-type=propdesc title=grid-auto-flow>grid-auto-flow</span> property</a></ul>
<li><a href=#grid-shorthand><span class=secno>7</span> Grid Definition Shorthand: the <span class=property data-link-type=propdesc title=grid>grid</span> property</a>
<li><a href=#placement><span class=secno>8</span> Placing Grid Items</a>
<ul class=toc>
<li><a href=#common-uses><span class=secno>8.1</span> Common Patterns for Grid Placement</a>
<ul class=toc>
<li><a href=#common-uses-named-areas><span class=secno>8.1.1</span> Named Areas</a>
<li><a href=#common-uses-numeric><span class=secno>8.1.2</span> Numeric Indexes and Spans</a>
<li><a href=#common-uses-named-lines><span class=secno>8.1.3</span> Named Lines and Spans</a>
<li><a href=#common-uses-auto-placement><span class=secno>8.1.4</span> Auto Placement</a>
<li><a href=#common-uses-auto-sizing><span class=secno>8.1.5</span> Auto Sizing Subgrids</a></ul>
<li><a href=#line-placement><span class=secno>8.2</span> Line-based Placement: the <span class=property data-link-type=propdesc title=grid-row-start>grid-row-start</span>, <span class=property data-link-type=propdesc title=grid-column-start>grid-column-start</span>, <span class=property data-link-type=propdesc title=grid-row-end>grid-row-end</span>, and <span class=property data-link-type=propdesc title=grid-column-end>grid-column-end</span> properties</a>
<ul class=toc>
<li><a href=#grid-placement-errors><span class=secno>8.2.1</span> Grid Placement Conflict Handling</a></ul>
<li><a href=#placement-shorthands><span class=secno>8.3</span> Placement Shorthands: the <span class=property data-link-type=propdesc title=grid-column>grid-column</span>, <span class=property data-link-type=propdesc title=grid-row>grid-row</span>, and <span class=property data-link-type=propdesc title=grid-area>grid-area</span> properties</a>
<li><a href=#abspos-items><span class=secno>8.4</span> Absolutely-positioned Grid Items</a>
<li><a href=#auto-placement-algo><span class=secno>8.5</span> Grid Item Placement Algorithm</a></ul>
<li><a href=#alignment><span class=secno>9</span> Alignment</a>
<ul class=toc>
<li><a href=#auto-margins><span class=secno>9.1</span> Aligning with <span data-link-for=margin data-link-type=value title=auto>auto</span> margins</a>
<li><a href=#row-align><span class=secno>9.2</span> Row-axis Alignment: the <span class=property data-link-type=propdesc title=justify-self>justify-self</span> and <span class=property data-link-type=propdesc title=justify-items>justify-items</span> properties</a>
<li><a href=#column-align><span class=secno>9.3</span> Column-axis Alignment: the <span class=property data-link-type=propdesc title=align-self>align-self</span> and <span class=property data-link-type=propdesc title=align-items>align-items</span> properties</a>
<li><a href=#grid-align><span class=secno>9.4</span> Aligning the Grid: the <span class=property data-link-type=propdesc title=justify-content>justify-content</span> and <span class=property data-link-type=propdesc title=align-content>align-content</span> properties</a>
<li><a href=#z-order><span class=secno>9.5</span> Z-axis Ordering: the <span class=property data-link-type=propdesc title=z-index>z-index</span> property</a>
<li><a href=#grid-baselines><span class=secno>9.6</span> Grid Baselines</a></ul>
<li><a href=#layout-algorithm><span class=secno>10</span> Track Sizing Algorithm</a>
<ul class=toc>
<li><a href=#algo-terms><span class=secno>10.1</span> Definition of Terms for use in Calculating Grid Track Sizes</a>
<li><a href=#algo-overview><span class=secno>10.2</span> Overall Sizing Algorithm</a>
<li><a href=#algo-init><span class=secno>10.3</span> Initialize Track Sizes</a>
<li><a href=#algo-content><span class=secno>10.4</span> Resolve Content-Based Track Sizing Functions</a>
<li><a href=#algo-grow-tracks><span class=secno>10.5</span> Grow All Tracks To Their Max</a>
<li><a href=#algo-flex-tracks><span class=secno>10.6</span> Process Flexible Tracks</a>
<ul class=toc>
<li><a href=#algo-find-fr-size><span class=secno>10.6.1</span> Find the Size of an <span class=css data-link-type=maybe title=fr>fr</span></a></ul></ul>
<li><a href=#pagination><span class=secno>11</span> Fragmenting Grid Layout</a>
<li><a href=#acks><span class=secno></span> Acknowledgements</a>
<li><a href=#changes><span class=secno></span> Changes</a>
<li><a href=#translated-algo><span class=secno></span> Appendix A: Translated Layout Algorithm</a>
<li><a href=#conformance><span class=secno></span> Conformance</a>
<ul class=toc>
<li><a href=#conventions><span class=secno></span> Document conventions</a>
<li><a href=#conformance-classes><span class=secno></span> Conformance classes</a>
<li><a href=#partial><span class=secno></span> Partial implementations</a>
<li><a href=#experimental><span class=secno></span> Experimental implementations</a>
<li><a href=#testing><span class=secno></span> Non-experimental implementations</a></ul>
<li><a href=#references><span class=secno></span> References</a>
<ul class=toc>
<li><a href=#normative><span class=secno></span> Normative References</a>
<li><a href=#informative><span class=secno></span> Informative References</a></ul>
<li><a href=#index><span class=secno></span> Index</a>
<li><a href=#property-index><span class=secno></span> Property index</a>
<li><a href=#issues-index><span class=secno></span> Issues Index</a></ul></div>
<h2 class="heading settled heading" data-level=1 id=intro><span class=secno>1 </span><span class=content>
Introduction and Overview</span><a class=self-link href=#intro></a></h2>
<p>Grid layout contains features targeted at web application authors.
The grid can be used to achieve many different layouts.
It excels at dividing up space for major regions of an application,
or defining the relationship in terms of size, position, and layer
between parts of a control built from HTML primitives.</p>
<p>Like tables,
grid layout enables an author to align elements into columns and rows,
but unlike tables,
grid layout doesn’t have content structure,
and thus enables a wide variety of layouts not possible with tables.
For example, the children of a grid container can position themselves
such that they overlap and layer similar to positioned elements.</p>
<p>In addition, the absence of content structure in grid layout helps to manage changes to layout
by using fluid and source order independent layout techniques.
By combining media queries with the CSS properties that control layout of the grid container and its children,
authors can adapt their layout to changes in device form factors, orientation, and available space,
without needing to alter the semantic nature of their content.</p>
<h3 class="heading settled heading" data-level=1.1 id=background><span class=secno>1.1 </span><span class=content>
Background and Motivation</span><a class=self-link href=#background></a></h3>
<figure class=sidefigure>
<img alt="Image: Application layout example requiring horizontal and vertical alignment." class=figure src=images/basic-form.png>
<figcaption>Application layout example requiring horizontal and vertical alignment.</figcaption>
</figure>
<p>As websites evolved from simple documents into complex, interactive applications,
tools for document layout, e.g. floats,
were not necessarily well suited for application layout.
By using a combination of tables, JavaScript, or careful measurements on floated elements,
authors discovered workarounds to achieve desired layouts.
Layouts that adapted to the available space were often brittle
and resulted in counter-intuitive behavior as space became constrained.
As an alternative, authors of many web applications opted for a fixed layout
that cannot take advantage of changes in the available rendering space on a screen.</p>
<p>The capabilities of grid layout address these problems.
It provides a mechanism for authors to divide available space for layout into columns and rows
using a set of predictable sizing behaviors.
Authors can then precisely position and size the building block elements of their application
by into <a data-link-type=dfn href=#grid-area title="grid areas">grid areas</a> defined by these columns and rows.
Figure 1 illustrates a basic layout which can be achieved with grid layout.</p>
<h3 class="heading settled heading" data-level=1.2 id=adapting-to-available-space><span class=secno>1.2 </span><span class=content>
Adapting Layouts to Available Space</span><a class=self-link href=#adapting-to-available-space></a></h3>
<figure class=sidefigure>
<img alt="Image: Five grid items arranged according to content size and available space." src=images/game-smaller.png>
<figcaption>Five grid items arranged according to content size and available space.</figcaption>
</figure>
<figure class=sidefigure>
<img alt="Image: Growth in the grid due to an increase in available space." src=images/game-larger.png>
<figcaption>Growth in the grid due to an increase in available space.</figcaption>
</figure>
<p>Grid layout can be used to intelligently reflow elements within a webpage.
Figure 2 represents a game with five major areas in the layout:
the game title, stats area, game board, score area, and control area.
The author’s intent is to divide the space for the game such that:</p>
<ul>
<li>
The stats area always appears immediately under the game title.
<li>
The game board appears to the right of the stats and title.
<li>
The top of the game title and the game board should always align.
<li>
The bottom of the game board and the stats area align when the game has reached its minimum height,
but otherwise the game board will stretch to take advantage of all the screen real-estate available to it.
<li>
The score area should align into the column created by the game and stats area,
while the controls are centered under the board.
</ul>
<p>As an alternative to using script to control the absolute position, width, and height of all elements,
the author can use grid layout,
as shown in Figure 3.
The following example shows how an author might achieve all the sizing, placement, and alignment rules declaratively.</p>
<p>Note that there are multiple ways to specify the structure of the grid
and to position and size <a data-link-type=dfn href=#grid-item title="grid items">grid items</a>,
each optimized for different scenarios.
This example illustrates one that an author may use to define the position and space for each <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>
using the <a class=property data-link-type=propdesc href=#propdef-grid-template-rows title=grid-template-rows>grid-template-rows</a> and <a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a> properties on the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>,
and the <a class=property data-link-type=propdesc href=#propdef-grid-row title=grid-row>grid-row</a> and <a class=property data-link-type=propdesc href=#propdef-grid-column title=grid-column>grid-column</a> properties on each <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>.</p>
<pre class=example><style type="text/css">
#grid {
display: grid;
/* Two columns: the first sized to content, the second receives
* the remaining space, but is never smaller than the minimum
* size of the board or the game controls, which occupy this
* column. */
grid-template-columns: auto minmax(min-content, 1fr);
/* Three rows: the first and last sized to content, the middle
* row receives the remaining space, but is never smaller than
* the minimum height of the board or stats areas. */
grid-template-rows: auto minmax(min-content, 1fr) auto
}
/* Each part of the game is positioned between grid lines by
* referencing the starting grid line and then specifying, if more
* than one, the number of rows or columns spanned to determine
* the ending grid line, which establishes bounds for the part. */
#title { grid-column: 1; grid-row: 1 }
#score { grid-column: 1; grid-row: 3 }
#stats { grid-column: 1; grid-row: 2; justify-self: start }
#board { grid-column: 2; grid-row: 1 / span 2; }
#controls { grid-column: 2; grid-row: 3; align-self: center }
</style>
<div id="grid">
<div id="title">Game Title</div>
<div id="score">Score</div>
<div id="stats">Stats</div>
<div id="board">Board</div>
<div id="controls">Controls</div>
</div>
</pre>
<h3 class="heading settled heading" data-level=1.3 id=source-independence><span class=secno>1.3 </span><span class=content>
Source Independence</span><a class=self-link href=#source-independence></a></h3>
<figure class=sidefigure>
<img alt="Image: An arrangement suitable for portrait orientation." src=images/game-portrait.png>
<figcaption>An arrangement suitable for <span class=css data-link-type=maybe title=portrait>portrait</span> orientation.</figcaption>
</figure>
<figure class=sidefigure>
<img alt="Image: An arrangement suitable for landscape orientation." src=images/game-landscape.png>
<figcaption>An arrangement suitable for <span class=css data-link-type=maybe title=landscape>landscape</span> orientation.</figcaption>
</figure>
<p>Continuing the prior example,
the author also wants the game to adapt to the space available on traditional computer monitors, handheld devices, or tablet computers.
Also, the game should optimize the placement of the components when viewed either in landscape or portrait orientation (Figures 4 and 5).
By combining grid layout with media queries,
the author is able to use the same semantic markup,
but rearrange the layout of elements independent of their source order,
to achieve the desired layout in both orientations.</p>
<p>The following example leverages grid layout’s ability to name the space which will be occupied by a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>.
This allows the author to avoid rewriting rules for <a data-link-type=dfn href=#grid-item title="grid items">grid items</a>
as the grid’s definition changes.</p>
<pre class=example><style type="text/css">
@media (orientation: portrait) {
#grid {
display: grid;
/* The rows, columns and areas of the grid are defined visually
* using the grid-template-areas property. Each string is a row, and
* each word an area. The number of words in a string
* determines the number of columns. Note the number of words
* in each string must be identical. */
grid-template-areas: "title stats"
"score stats"
"board board"
"ctrls ctrls";
/* Columns and rows created with the template property can be
* assigned a sizing function with the grid-template-columns
* and grid-template-rows properties. */
grid-template-columns: auto minmax(min-content, 1fr);
grid-template-rows: auto auto minmax(min-content, 1fr) auto
}
}
@media (orientation: landscape) {
#grid {
display: grid;
/* Again the template property defines areas of the same name,
* but this time positioned differently to better suit a
* landscape orientation. */
grid-template-areas: "title board"
"stats board"
"score ctrls";
grid-template-columns: auto minmax(min-content, 1fr);
grid-template-rows: auto minmax(min-content, 1fr) auto
}
}
/* The grid-area property places a grid item into a named
* region (area) of the grid. */
#title { grid-area: title }
#score { grid-area: score }
#stats { grid-area: stats }
#board { grid-area: board }
#controls { grid-area: ctrls }
</style>
<div id="grid">
<div id="title">Game Title</div>
<div id="score">Score</div>
<div id="stats">Stats</div>
<div id="board">Board</div>
<div id="controls">Controls</div>
</div>
</pre>
<h3 class="heading settled heading" data-level=1.4 id=grid-layering><span class=secno>1.4 </span><span class=content>
Grid Layering of Elements</span><a class=self-link href=#grid-layering></a></h3>
<figure class=sidefigure>
<img alt="Image: A control composed of layered HTML elements." src=images/control-layering-and-alignment.png>
<figcaption>A control composed of layered HTML elements.</figcaption>
</figure>
<p>In the example shown in Figure 6,
the author is creating a custom slider control.
The control has six parts.
The lower and upper labels align to the left and right edges of the control.
The track of the slider spans the area between the labels.
The lower and upper fill parts touch beneath the thumb,
and the thumb is a fixed width and height that can be moved along the track
by updating the two flex-sized columns.</p>
<p>Prior to the introduction of grid layout,
the author would have likely used absolute positioning to control the top and left coordinates,
along with the width and height of each HTML element that comprises the control.
By leveraging grid layout,
the author can instead limit script usage to handling mouse events on the thumb,
which snaps to various positions along the track
as the <a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a> property of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is updated.</p>
<pre class=example><style type="text/css">
#grid {
display: grid;
/* The grid-template-columns and rows properties also support
* naming grid lines which can then be used to position grid
* items. The line names are assigned on either side of a column
* or row sizing function where the line would logically exist. */
grid-template-columns:
(start) auto
(track-start) 0.5fr
(thumb-start) auto
(fill-split) auto
(thumb-end) 0.5fr
(track-end) auto
(end);
}
/* The grid-placement properties accept named lines. Below the
* lines are referred to by name. Beyond any
* semantic advantage, the names also allow the author to avoid
* renumbering the grid-column-start and grid-row-start properties of the
* grid items. This is similar to the concept demonstrated in the
* prior example with the grid-template-areas property during orientation
* changes, but grid lines can also work with layered grid items
* that have overlapping areas of different shapes like the thumb
* and track parts in this example. */
#lower-label { grid-column-start: start }
#track { grid-column: track-start / track-end; align-self: center }
#upper-label { grid-column-end: end; }
/* Fill parts are drawn above the track so set z-index to 5. */
#lower-fill { grid-column: track-start / fill-split;
align-self: end;
z-index: 5 }
#upper-fill { grid-column: fill-split / track-end;
align-self: start;
z-index: 5 }
/* Thumb is the topmost part; assign it the highest z-index value. */
#thumb { grid-column: thumb-start / thumb-end; z-index: 10 }
</style>
<div id="grid">
<div id="lower-label">Lower Label</div>
<div id="upper-label">Upper Label</div>
<div id="track">Track</div>
<div id="lower-fill">Lower Fill</div>
<div id="upper-fill">Upper Fill</div>
<div id="thumb">Thumb</div>
</div>
</pre>
<h2 class="heading settled heading" data-level=2 id=grid-concepts><span class=secno>2 </span><span class=content>
Grid Layout Concepts and Terminology</span><a class=self-link href=#grid-concepts></a></h2>
<p>In <dfn data-dfn-type=dfn data-export="" id=grid-layout>grid layout<a class=self-link href=#grid-layout></a></dfn>,
the content of a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is laid out
by positioning and aligning it into a <a data-link-type=dfn href=#grid title=grid>grid</a>.
The <dfn data-dfn-type=dfn data-export="" id=grid>grid<a class=self-link href=#grid></a></dfn> is an intersecting set of horizontal and vertical <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>
that divides the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>’s space into <a data-link-type=dfn href=#grid-area title="grid areas">grid areas</a>,
into which <a data-link-type=dfn href=#grid-item title="grid items">grid items</a> (representing the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>’s content) can be placed.
There are two sets of <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>:
one set defining <dfn data-dfn-type=dfn data-export="" id=grid-column title="grid column | column">columns<a class=self-link href=#grid-column></a></dfn>
that run along the <a href=http://www.w3.org/TR/css3-writing-modes/#block-axis->block axis</a> (the <dfn data-dfn-type=dfn data-export="" id=column-axis>column axis<a class=self-link href=#column-axis></a></dfn>),
and an orthogonal set defining <dfn data-dfn-type=dfn data-export="" id=grid-row title="grid row | row">rows<a class=self-link href=#grid-row></a></dfn>
along the <a href=http://www.w3.org/TR/css3-writing-modes/#inline-axis->inline axis</a> (the <dfn data-dfn-type=dfn data-export="" id=row-axis>row axis<a class=self-link href=#row-axis></a></dfn>).
<a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-writing-modes title=biblio-css3-writing-modes>[CSS3-WRITING-MODES]</a></p>
<figure>
<img alt="Image: Grid Lines." class=figure src=images/grid-lines.png>
<figcaption>Grid lines: Three in the block axis and four in the inline axis.</figcaption>
</figure>
<h3 class="heading settled heading" data-level=2.1 id=grid-track-concept><span class=secno>2.1 </span><span class=content>
Grid Tracks and Cells</span><a class=self-link href=#grid-track-concept></a></h3>
<p><dfn data-dfn-type=dfn data-export="" id=grid-track>Grid track<a class=self-link href=#grid-track></a></dfn> is a generic term for a <a data-link-type=dfn href=#grid-column title="grid column">grid column</a> or <a data-link-type=dfn href=#grid-row title="grid row">grid row</a>—in
other words, it is the space between two adjacent <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>.
Each <a data-link-type=dfn href=#grid-track title="grid track">grid track</a> is assigned a sizing function,
which controls how wide or tall the column or row may grow,
and thus how far apart its bounding <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a> are.</p>
<p>A <dfn data-dfn-type=dfn data-export="" id=grid-cell>grid cell<a class=self-link href=#grid-cell></a></dfn> is the similar term for the full grid—it
is the space between two adjacent row and two adjacent column <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>.
It is the smallest unit of the grid that can be referenced when positioning <a data-link-type=dfn href=#grid-item title="grid items">grid items</a>.</p>
<div class=example>
In the following example there are two columns and three rows.
The first column is fixed at 150px.
The second column uses flexible sizing, which is a function of the unassigned space in the Grid,
and thus will vary as the width of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> changes.
If the used width of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is 200px, then the second column 50px wide.
If the used width of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is 100px, then the second column is 0px
and any content positioned in the column will overflow the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>.
<pre><style type="text/css">
#grid {
display: grid;
grid-template-columns: 150px 1fr; /* two columns */
grid-template-rows: 50px 1fr 50px /* three rows */
}
</style>
</pre>
</div>
<h3 class="heading settled heading" data-level=2.2 id=grid-line-concept><span class=secno>2.2 </span><span class=content>
Grid Lines</span><a class=self-link href=#grid-line-concept></a></h3>
<p><dfn data-dfn-type=dfn data-export="" id=grid-line title="grid line|grid row line|grid column line">Grid lines<a class=self-link href=#grid-line></a></dfn> are the horizontal and vertical dividing lines of the <a data-link-type=dfn href=#grid title=grid>grid</a>.
A <a data-link-type=dfn href=#grid-line title="grid line">grid line</a> exists on either side of a column or row.
They can be referred to by numerical index,
or by an author-specified name.
A <a data-link-type=dfn href=#grid-item title="grid item">grid item</a> references the <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a> to determine its position within the <a data-link-type=dfn href=#grid title=grid>grid</a>
using the <a href=#placement>grid-placement properties</a>.</p>
<div class=example>
The following two examples create three column <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a> and four row <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>.
The first example demonstrates how an author would position a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a> using <a data-link-type=dfn href=#grid-line title="grid line">grid line</a> numbers.
The second example uses explicitly named <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>.
<pre><style type="text/css">
#grid {
display: grid;
grid-template-columns: 150px 1fr;
grid-template-rows: 50px 1fr 50px
}
#item1 { grid-column: 2;
grid-row-start: 1; grid-row-end: 4; }
</style>
</pre>
<pre><style type="text/css">
/* equivalent layout to the prior example, but using named lines */
#grid {
display: grid;
grid-template-columns: 150px (item1-start) 1fr (item1-end);
grid-template-rows: (item1-start) 50px 1fr 50px (item1-end);
}
#item1 {
grid-column: item1-start / item1-end;
grid-row: item1-start / item1-end
}
</style>
</pre>
</div>
<h3 class="heading settled heading" data-level=2.3 id=grid-area-concept><span class=secno>2.3 </span><span class=content>
Grid Areas</span><a class=self-link href=#grid-area-concept></a></h3>
<p>A <dfn data-dfn-type=dfn data-export="" id=grid-area>grid area<a class=self-link href=#grid-area></a></dfn> is the logical space used to lay out one or more <a data-link-type=dfn href=#grid-item title="grid items">grid items</a>.
It is bound by four <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>, one on each side of the <a data-link-type=dfn href=#grid-area title="grid area">grid area</a>,
and participates in the sizing of the <a data-link-type=dfn href=#grid-track title="grid tracks">grid tracks</a> it intersects.
A <a data-link-type=dfn href=#grid-area title="grid area">grid area</a> can be named explicitly using the <a class=property data-link-type=propdesc href=#propdef-grid-template-areas title=grid-template-areas>grid-template-areas</a> property of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>,
or referenced implicitly by its bounding <a data-link-type=dfn href=#grid-line title="grid lines">grid lines</a>.
A <a data-link-type=dfn href=#grid-item title="grid item">grid item</a> is assigned to a <a data-link-type=dfn href=#grid-area title="grid area">grid area</a>
using the <a href=#placement>grid-placement properties</a>.</p>
<div class=example>
<pre><style type="text/css">
/* using the template syntax */
#grid {
display: grid;
grid-template-areas: ". a"
"b a"
". a";
grid-template-columns: 150px 1fr;
grid-template-rows: 50px 1fr 50px
}
#item1 { grid-area: a }
#item2 { grid-area: b }
#item3 { grid-area: b }
/* Align items 2 and 3 at different points in the Grid Area "b". */
/* By default, Grid Items are stretched to fit their Grid Area */
/* and these items would layer one over the other. */
#item2 { align-self: start }
#item3 { justify-self: end; align-self: end }
</style>
</pre>
</div>
<p>A <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>’s <a data-link-type=dfn href=#grid-area title="grid area">grid area</a> forms the containing block into which it is laid out.
Percentage lengths specified on a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a> resolve against this containing block.
Percentages specified for <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/box.html#propdef-margin-top title=margin-top>margin-top</a>, <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/box.html#propdef-padding-top title=padding-top>padding-top</a>, <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/box.html#propdef-margin-bottom title=margin-bottom>margin-bottom</a>, and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/box.html#propdef-padding-bottom title=padding-bottom>padding-bottom</a> on a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>
resolve against the height of its containing block,
rather than the width (as for blocks).</p>
<p><a data-link-type=dfn href=#grid-item title="grid items">Grid items</a> placed into the same <a data-link-type=dfn href=#grid-area title="grid area">grid area</a> do not directly affect each other’s layout.
Indirectly, a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a> can affect the position of a <a data-link-type=dfn href=#grid-line title="grid line">grid line</a> in a column or row that uses a contents-based relative size,
which in turn can affect the position or size of another <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>.</p>
<h2 class="heading settled heading" data-level=3 id=grid-model><span class=secno>3 </span><span class=content>
Grid Containers</span><a class=self-link href=#grid-model></a></h2>
<h3 class="heading settled heading" data-level=3.1 id=grid-containers><span class=secno>3.1 </span><span class=content>
Establishing Grid Containers: the <a class=css data-link-for=display data-link-type=maybe href=#valuedef-grid title=grid>grid</a> and <a class=css data-link-type=maybe href=#valuedef-inline-grid title=inline-grid>inline-grid</a> <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> values</span><a class=self-link href=#grid-containers></a></h3>
<table class="definition propdef partial"><tr><th>Name:<td><a class=css-code data-link-type=property href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a><tr><th>New values:<td class=prod>grid <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> inline-grid</table>
<dl data-dfn-for=display data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for=display data-dfn-type=value data-export="" id=valuedef-grid>grid<a class=self-link href=#valuedef-grid></a></dfn>
<dd>
This value causes an element to generate a block-level <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> box.
<dt><dfn class=css-code data-dfn-for=display data-dfn-type=value data-export="" id=valuedef-inline-grid>inline-grid<a class=self-link href=#valuedef-inline-grid></a></dfn>
<dd>
This value causes an element to generate an inline-level <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> box.
</dl>
<p>A <dfn data-dfn-type=dfn data-export="" id=grid-container>grid container<a class=self-link href=#grid-container></a></dfn> establishes a new <dfn data-dfn-type=dfn data-export="" id=grid-formatting-context>grid formatting context<a class=self-link href=#grid-formatting-context></a></dfn> for its contents.
This is the same as establishing a block formatting context,
except that grid layout is used instead of block layout:
floats do not intrude into the grid container,
and the grid container’s margins do not collapse with the margins of its contents.
<a data-link-type=dfn href=#grid-container title="grid containers">Grid containers</a> form a containing block for their contents
<a href=http://www.w3.org/TR/CSS21/visudet.html#containing-block-details>exactly like block containers do</a>. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-css21>[CSS21]</a>
The <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-overflow-3/#overflow0 title=overflow>overflow</a> property applies to <a data-link-type=dfn href=#grid-container title="grid containers">grid containers</a>.</p>
<p>Grid containers are not block containers,
and so some properties that were designed with the assumption of block layout
don’t apply in the context of grid layout.
In particular:</p>
<ul>
<li>
all of the <a class=property data-link-type=propdesc title=column-*>column-*</a> properties in the Multicol module have no effect on a grid container.
<li>
<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-float title=float>float</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-clear title=clear>clear</a> have no effect on a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>.
(However, the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-float title=float>float</a> property still affects the computed value of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> on children of a grid container,
as this occurs <em title="">before</em> <a data-link-type=dfn href=#grid-item title="grid items">grid items</a> are determined.)
<li>
<a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visudet.html#propdef-vertical-align title=vertical-align>vertical-align</a> has no effect on a grid item.
<li>
the <span class=css data-link-type=maybe title=::first-line>::first-line</span> and <span class=css data-link-type=maybe title=::first-letter>::first-letter</span> pseudo-elements do not apply to <a data-link-type=dfn href=#grid-container title="grid containers">grid containers</a>.
</ul>
<p>If an element’s specified <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> is <a class=css data-link-type=maybe href=#valuedef-inline-grid title=inline-grid>inline-grid</a>
and the element is floated or absolutely positioned,
the computed value of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> is <a class=css-code data-link-type=value href=#valuedef-grid title=grid>grid</a>.
The table in <a href=http://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo>CSS 2.1 Chapter 9.7</a> is thus amended
to contain an additional row,
with <a class=css data-link-type=maybe href=#valuedef-inline-grid title=inline-grid>inline-grid</a> in the "Specified Value" column
and <a data-link-type=dfn href=#grid title=grid>grid</a> in the "Computed Value" column.</p>
<h3 class="heading settled heading" data-level=3.2 id=intrinsic-sizes><span class=secno>3.2 </span><span class=content>
Sizing Grid Containers</span><a class=self-link href=#intrinsic-sizes></a></h3>
<p>A <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is sized
using the rules of the formatting context in which it participates.
As a block-level box in a <a data-link-type=dfn title="block formatting context">block formatting context</a>,
it is sized like any other block-level box that establishes a formatting context,
with an <a class=css data-link-type=maybe href=#valuedef-auto title=auto>auto</a> inline size calculated as for in-flow block boxes.
As an inline-level box in an inline formatting context,
it is sized as an atomic inline-level box (such as an inline-block).
In both inline and block formatting contexts,
the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>’s <a class=css data-link-type=maybe href=#valuedef-auto title=auto>auto</a> block size is its max-content size.
<span class=issue id=issue-839d056f><a class=self-link href=#issue-839d056f></a>The block layout spec should define this?</span></p>
<p>The <a data-link-type=dfn href=http://dev.w3.org/csswg/css-sizing-3/#max-content-measure title="max-content size">max-content size</a> of a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is
the sum of the <a data-link-type=dfn href=#grid-container title="grid container’s">grid container’s</a> track sizes in the appropriate axis,
when the grid is sized under a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-sizing-3/#max-content-constraint title="max-content constraint">max-content constraint</a>.</p>
<p>The <a data-link-type=dfn href=http://dev.w3.org/csswg/css-sizing-3/#min-content-measure title="min-content size">min-content size</a> of a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is
the sum of the <a data-link-type=dfn href=#grid-container title="grid container’s">grid container’s</a> track sizes in the appropriate axis,
when the grid is sized under a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-sizing-3/#min-content-constraint title="min-content constraint">min-content constraint</a>.</p>
<p>See <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3-sizing title=biblio-css3-sizing>[CSS3-SIZING]</a> for a definition of the terms in this section.</p>
<h2 class="heading settled heading" data-level=4 id=grid-items><span class=secno>4 </span><span class=content>
Grid Items</span><a class=self-link href=#grid-items></a></h2>
<p>The contents of a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> consists of zero or more <dfn data-dfn-type=dfn data-export="" id=grid-item title="grid item">grid items<a class=self-link href=#grid-item></a></dfn>:
each child of a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>
becomes a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>,
and each contiguous run of text that is directly contained inside a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>
is wrapped in an anonymous <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>.
However, an anonymous grid item that contains only
<a href=http://www.w3.org/TR/CSS21/text.html#white-space-prop>white space</a>
is not rendered, as if it were <span class=css data-link-type=maybe title=display:none>display:none</span>.</p>
<p>A <a data-link-type=dfn href=#grid-item title="grid item">grid item</a> establishes a new formatting context for its contents.
The type of this formatting context is determined by its <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> value, as usual.
The computed <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> of a <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>
is determined by applying the table in
<a href=http://www.w3.org/TR/CSS2/visuren.html#dis-pos-flo>CSS 2.1 Chapter 9.7</a>.
However, grid items are grid-level boxes, not block-level boxes:
they participate in their container’s <a data-link-type=dfn href=#grid-formatting-context title="grid formatting context">grid formatting context</a>,
not in a block formatting context.</p>
<div class=example>
Examples of grid items:
<pre><div style="display:grid">
<!-- grid item: block child -->
<div id="item1">block</div>
<!-- grid item: floated element; floating is ignored -->
<div id="item2" style="float: left;">float</div>
<!-- grid item: anonymous block box around inline content -->
anonymous item 3
<!-- grid item: inline child -->
<span>
item 4
<!-- grid items do not split around blocks -->
<div id=not-an-item>item 4</div>
item 4
</span>
</div></pre>
</div>
<p>Some values of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visuren.html#propdef-display title=display>display</a> trigger the generation of anonymous boxes.
For example, a misparented <span class=css data-link-type=maybe title=table-cell>table-cell</span> child is fixed up
by <a href=http://www.w3.org/TR/CSS21/tables.html#anonymous-boxes>generating anonymous </a><span class=css data-link-type=maybe title=table>table</span> and <span class=css data-link-type=maybe title=table-row>table-row</span> elements around it. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-css21>[CSS21]</a>
This fixup must occur <em>before</em> a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>’s children are promoted to <a data-link-type=dfn href=#grid-item title="grid items">grid items</a>.
For example, given two contiguous child elements with <span class=css data-link-type=maybe title=display:table-cell>display:table-cell</span>,
an anonymous table wrapper box around them becomes the <a data-link-type=dfn href=#grid-item title="grid item">grid item</a>.</p>
<p class=note>
Future display types may generate anonymous containers (e.g. ruby) or otherwise mangle the box tree (e.g. run-ins).
It is intended that grid item determination run after these operations.
<h3 class="heading settled heading" data-level=4.1 id=visibility-collapse><span class=secno>4.1 </span><span class=content>
Collapsed Grid Items: the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css2/visufx.html#propdef-visibility title=visibility>visibility</a> property</span><a class=self-link href=#visibility-collapse></a></h3>
<p class=issue id=issue-8f83c1bc><a class=self-link href=#issue-8f83c1bc></a>
We want the ability to collapse grid tracks
(similar to <a href=http://www.w3.org/TR/css3-flexbox/#visibility-collapse>collapsing flex items</a>
or <a href=http://www.w3.org/TR/CSS21/tables.html#dynamic-effects>table rows/columns</a>),
but we’re not sure exactly how to do it.
Ideas welcome, please <a href="mailto:www-style@w3.org?Subject=%5Bcss-grid%5D%20Collapsing%20Grid%20Tracks">post them to www-style@w3.org</a>.
<h3 class="heading settled heading" data-level=4.2 id=order-property><span class=secno>4.2 </span><span class=content>
Reordered Grid Items: the <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-flexbox-1/#propdef-order title=order>order</a> property</span><a class=self-link href=#order-property></a></h3>
<p>The <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-flexbox-1/#propdef-order title=order>order</a> property also applies to <a data-link-type=dfn href=#grid-item title="grid items">grid items</a>.
It affects their <a href=#grid-auto-flow-property>auto-placement</a> and <a href=#z-order>painting order</a>.</p>
<h3 class="heading settled heading" data-level=4.3 id=static-position><span class=secno>4.3 </span><span class=content>
Static Position of Grid Container Children</span><a class=self-link href=#static-position></a></h3>
<p>The <a href=http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width>static position</a> <a data-biblio-type=normative data-link-type=biblio href=#biblio-css21 title=biblio-css21>[CSS21]</a>
of an absolutely-positioned child of a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>
is determined as if it were the sole grid item
in a fixed-size <a data-link-type=dfn href=#grid-area title="grid area">grid area</a>
whose edges coincide with the padding edges of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>.</p>
<p class=note>Note: Note that this position is affected by the values of <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-align-3/#propdef-justify-self title=justify-self>justify-self</a> and <a class=property data-link-type=propdesc href=http://dev.w3.org/csswg/css-align-3/#propdef-align-self title=align-self>align-self</a> on the child,
and that, as in most other layout models,
the absolutely-positioned child has no effect on the size of the containing block
or layout of its contents.</p>
<h2 class="heading settled heading" data-level=5 id=grid-definition><span class=secno>5 </span><span class=content>
The Explicit Grid</span><a class=self-link href=#grid-definition></a></h2>
<p>The three properties <a class=property data-link-type=propdesc href=#propdef-grid-template-rows title=grid-template-rows>grid-template-rows</a>, <a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a>, and <a class=property data-link-type=propdesc href=#propdef-grid-template-areas title=grid-template-areas>grid-template-areas</a>
together define the <dfn data-dfn-type=dfn data-export="" id=explicit-grid>explicit grid<a class=self-link href=#explicit-grid></a></dfn> of a <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>.
The <a class=property data-link-type=propdesc href=#propdef-grid-template title=grid-template>grid-template</a> property is a shorthand that sets all three at the same time.
The final grid may end up larger due to <a data-link-type=dfn href=#grid-item title="grid items">grid items</a> placed outside the <a data-link-type=dfn href=#explicit-grid title="explicit grid">explicit grid</a>;
in this case, any implicit tracks are sized by the <a class=property data-link-type=propdesc href=#propdef-grid-auto-rows title=grid-auto-rows>grid-auto-rows</a> and <a class=property data-link-type=propdesc href=#propdef-grid-auto-columns title=grid-auto-columns>grid-auto-columns</a> properties.</p>
<p>The size of the <a data-link-type=dfn href=#explicit-grid title="explicit grid">explicit grid</a> is determined by the larger of
the number of rows/columns defined by <a class=property data-link-type=propdesc href=#propdef-grid-template-areas title=grid-template-areas>grid-template-areas</a>
and the number of rows/columns sized by <a class=property data-link-type=propdesc href=#propdef-grid-template-rows title=grid-template-rows>grid-template-rows</a>/<a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a>.
Any rows/columns defined by <a class=property data-link-type=propdesc href=#propdef-grid-template-areas title=grid-template-areas>grid-template-areas</a> but not sized by <a class=property data-link-type=propdesc href=#propdef-grid-template-rows title=grid-template-rows>grid-template-rows</a>/<a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a>
take their size from the <a class=property data-link-type=propdesc href=#propdef-grid-auto-rows title=grid-auto-rows>grid-auto-rows</a>/<a class=property data-link-type=propdesc href=#propdef-grid-auto-columns title=grid-auto-columns>grid-auto-columns</a> properties.</p>
<p>Numeric indexes in the <a data-link-type=dfn href=#grid-placement-property title="grid-placement properties">grid-placement properties</a>
count from the edges of the <a data-link-type=dfn href=#explicit-grid title="explicit grid">explicit grid</a>,
starting from 1.
Positive indexes count from the before/start side,
while negative indexes count from the after/end side.</p>
<h3 class="heading settled heading" data-level=5.1 id=track-sizing><span class=secno>5.1 </span><span class=content>
Track Sizing: the <a class=property data-link-type=propdesc href=#propdef-grid-template-rows title=grid-template-rows>grid-template-rows</a> and <a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a> properties</span><a class=self-link href=#track-sizing></a></h3>
<table class="definition propdef"><tr><th>Name:<td><dfn class=css-code data-dfn-type=property data-export="" id=propdef-grid-template-columns>grid-template-columns<a class=self-link href=#propdef-grid-template-columns></a></dfn>, <dfn class=css-code data-dfn-type=property data-export="" id=propdef-grid-template-rows>grid-template-rows<a class=self-link href=#propdef-grid-template-rows></a></dfn><tr><th>Value:<td class=prod>none <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> <a class="production css-code" data-link-type=type href=#typedef-track-list title="<track-list>"><track-list></a> <a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#comb-one title=|>|</a> subgrid <a class="production css-code" data-link-type=type href=#typedef-line-name-list title="<line-name-list>"><line-name-list></a><a class=prod-punc data-link-type=grammar href=http://dev.w3.org/csswg/css-values-3/#mult-opt title=?>?</a><tr><th>Initial:<td>none<tr><th>Applies to:<td><a data-link-type=dfn href=#grid-container title="grid containers">grid containers</a><tr><th>Inherited:<td>no<tr><th>Media:<td>visual<tr><th>Computed value:<td>As specified, except for <a class=css data-link-for=grid-template-columns data-link-type=maybe href=#valuedef-auto title=auto>auto</a> (see prose), with lengths made absolute<tr><th>Percentages:<td>refer to corresponding dimension of the content area</table>
<p>These properties specify,
as a space-separated <dfn data-dfn-type=dfn data-export="" id=track-list>track list<a class=self-link href=#track-list></a></dfn>,
the line names and <a data-link-type=dfn href=#track-sizing-function title="track sizing functions">track sizing functions</a> of the <a data-link-type=dfn href=#grid title=grid>grid</a>.
Each <dfn data-dfn-type=dfn data-noexport="" id=track-sizing-function title="track sizing function|sizing function">track sizing function<a class=self-link href=#track-sizing-function></a></dfn> can be specified as a length,
a percentage of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>’s size,
a measurement of the contents occupying the column or row,
or a fraction of the free space in the grid.
It can also be specified as a range using the <a class=css data-link-type=maybe href=#valuedef-minmax title=minmax()>minmax()</a> notation,
which can combine any of the previously mentioned mechanisms
to specify separate <a data-link-type=dfn href=#min-track-sizing-function title="min track sizing function">min</a>
and <a data-link-type=dfn href=#max-track-sizing-function title="max track sizing functions">max track sizing functions</a> for the column or row.</p>
<p>The <a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a> property specifies the <a data-link-type=dfn href=#track-list title="track list">track list</a> for the grid’s columns,
while <a class=property data-link-type=propdesc href=#propdef-grid-template-rows title=grid-template-rows>grid-template-rows</a> specifies the <a data-link-type=dfn href=#track-list title="track list">track list</a> for the grid’s rows.
The syntax of a <a data-link-type=dfn href=#track-list title="track list">track list</a> is:</p>
<pre><dfn class=css-code data-dfn-type=type data-export="" id=typedef-track-list><track-list><a class=self-link href=#typedef-track-list></a></dfn> = [ <a class="production css-code" data-link-type=type href=#typedef-line-names title="<line-names>"><line-names></a>? [ <a class="production css-code" data-link-type=type href=#typedef-track-size title="<track-size>"><track-size></a> | <a class="production css-code" data-link-type=function href=#funcdef-repeat title=repeat()><repeat()></a> ] ]+ <a class="production css-code" data-link-type=type href=#typedef-line-names title="<line-names>"><line-names></a>?
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-track-size><track-size><a class=self-link href=#typedef-track-size></a></dfn> = minmax( <a class="production css-code" data-link-type=type href=#typedef-track-breadth title="<track-breadth>"><track-breadth></a> , <a class="production css-code" data-link-type=type href=#typedef-track-breadth title="<track-breadth>"><track-breadth></a> ) | auto | <a class="production css-code" data-link-type=type href=#typedef-track-breadth title="<track-breadth>"><track-breadth></a>
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-track-breadth><track-breadth><a class=self-link href=#typedef-track-breadth></a></dfn> = <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a> | <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a> | <a class="production css-code" data-link-type=type href=#typedef-flex title="<flex>"><flex></a> | min-content | max-content
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-line-names><line-names><a class=self-link href=#typedef-line-names></a></dfn> = ( <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#identifier-value title="<custom-ident>"><custom-ident></a>* )
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-line-name-list><line-name-list><a class=self-link href=#typedef-line-name-list></a></dfn> = [ <a class="production css-code" data-link-type=type href=#typedef-line-names title="<line-names>"><line-names></a> | repeat(<a class="production css-code" data-link-type=type title="<positive-integer>"><positive-integer></a>, <a class="production css-code" data-link-type=type href=#typedef-line-names title="<line-names>"><line-names></a>+) ]+
</pre>
<p>Where:</p>
<dl data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value>
<dt><dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-export="" id=valuedef-length><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#length-value title="<length>"><length></a><a class=self-link href=#valuedef-length></a></dfn>
<dd>
A non-negative length, as defined by CSS3 Values. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3val title=biblio-css3val>[CSS3VAL]</a>
<dt><dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-export="" id=valuedef-percentage><a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a><a class=self-link href=#valuedef-percentage></a></dfn>
<dd>
A non-negative percentage, as defined by CSS3 Values. <a data-biblio-type=normative data-link-type=biblio href=#biblio-css3val title=biblio-css3val>[CSS3VAL]</a>
<a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a> values are relative to the measure (logical width) of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> in column <a data-link-type=dfn href=#grid-track title="grid tracks">grid tracks</a>,
and the extent (logical height) of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> in row <a data-link-type=dfn href=#grid-track title="grid tracks">grid tracks</a>.
If the measure or extent of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is an <a href=http://www.w3.org/TR/css3-sizing/#indefinite-size>indefinite size</a>,
<a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>"><percentage></a> values relative to that size are treated as <a class=css-code data-link-for=width data-link-type=value title=auto>auto</a>
(or, if in a <a class=css data-link-type=maybe href=#valuedef-minmax title=minmax()>minmax()</a> function, as <a class=css data-link-type=maybe href=#valuedef-min-content title=min-content>min-content</a> when in the first position
and as <a class=css data-link-type=maybe href=#valuedef-max-content title=max-content>max-content</a> when in the second).
<dt><dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-export="" id=valuedef-flex><a class="production css-code" data-link-type=type href=#typedef-flex title="<flex>"><flex></a><a class=self-link href=#valuedef-flex></a></dfn>
<dd>
A non-negative dimension with the unit <span class=css data-link-type=maybe title=fr>fr</span> specifying the track’s <dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-noexport="" id=valuedef-flex-factor>flex factor<a class=self-link href=#valuedef-flex-factor></a></dfn>.
Each <a class="production css-code" data-link-type=type href=#typedef-flex title="<flex>"><flex></a>-sized track takes a share of the remaining space in proportion to its <i data-link-type=dfn title="flex factor">flex factor</i>.
See <a href=#fr-unit>Flexible Lengths</a> for more details.
<dt><dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-export="" id=valuedef-max-content>max-content<a class=self-link href=#valuedef-max-content></a></dfn>
<dd>
Represents the largest <a data-link-type=dfn href=http://dev.w3.org/csswg/css-sizing-3/#max-content-contribution title="max-content contribution">max-content contribution</a>
of the <a data-link-type=dfn href=#grid-item title="grid items">grid items</a> occupying the <a data-link-type=dfn href=#grid-track title="grid track">grid track</a>.
<dt><dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-export="" id=valuedef-min-content>min-content<a class=self-link href=#valuedef-min-content></a></dfn>
<dd>
Represents the largest <a data-link-type=dfn href=http://dev.w3.org/csswg/css-sizing-3/#min-content-contribution title="min-content contribution">min-content contribution</a>
of the <a data-link-type=dfn href=#grid-item title="grid items">grid items</a> occupying the <a data-link-type=dfn href=#grid-track title="grid track">grid track</a>.
<dt><dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-export="" id=valuedef-minmax title=minmax()>minmax(min, max)<a class=self-link href=#valuedef-minmax></a></dfn>
<dd>
Defines a size range
greater than or equal to <var>min</var>
and less than or equal to <var>max</var>.
If <var>max</var> < <var>min</var>,
then <var>max</var> is ignored and <span class=css data-link-type=maybe title=minmax(min,max)>minmax(min,max)</span> is treated as <var>min</var>.
As a maximum, a <a class="production css-code" data-link-type=type href=#typedef-flex title="<flex>"><flex></a> value sets the track’s <i data-link-type=dfn title="flex factor">flex factor</i>.
As a minimum, it is treated as zero
(or <a class=css data-link-type=maybe href=#valuedef-min-content title=min-content>min-content</a>, if the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a> is sized under a <a data-link-type=dfn href=http://dev.w3.org/csswg/css-sizing-3/#min-content-constraint title="min-content constraint">min-content constraint</a>).
<dt><dfn class=css-code data-dfn-for="grid-template-columns grid-template-rows" data-dfn-type=value data-export="" id=valuedef-auto>auto<a class=self-link href=#valuedef-auto></a></dfn>
<dd>
Computes to <span class=css data-link-type=maybe title="minmax(min-content, max-content)">minmax(min-content, max-content)</span>.
</dl>
<p>The <dfn class=css-code data-dfn-for="grid-template-rows grid-template-columns" data-dfn-type=value data-export="" id=valuedef-none0>none<a class=self-link href=#valuedef-none0></a></dfn> value indicates that there is no <a data-link-type=dfn href=#explicit-grid title="explicit grid">explicit grid</a>;
any rows/columns will be implicitly generated,
and their size will be determined by the <a class=property data-link-type=propdesc href=#propdef-grid-auto-rows title=grid-auto-rows>grid-auto-rows</a> and <a class=property data-link-type=propdesc href=#propdef-grid-auto-columns title=grid-auto-columns>grid-auto-columns</a> properties.</p>
<p>The <dfn class=css-code data-dfn-for="grid-template-rows grid-template-columns" data-dfn-type=value data-export="" id=valuedef-subgrid0>subgrid<a class=self-link href=#valuedef-subgrid0></a></dfn> value indicates that the grid will align to its parent grid in that axis.
Rather than specifying the sizes of rows/columns explicitly,
they’ll be taken from the parent grid’s definition.</p>
<div class=example>
Given the following <a class=property data-link-type=propdesc href=#propdef-grid-template-columns title=grid-template-columns>grid-template-columns</a> declaration:
<pre>grid-template-columns: 100px 1fr max-content minmax(min-content, 1fr);</pre>
<p>Five grid lines are created:</p>
<ol>
<li>
At the start edge of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>.
<li>
100px from the start edge of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>.
<li>
A distance from the previous line equal to half the <a data-link-type=dfn href=#free-space title="free space">free space</a>
(the width of the <a data-link-type=dfn href=#grid-container title="grid container">grid container</a>, minus the width of the non-flexible <a data-link-type=dfn href=#grid-track title="grid tracks">grid tracks</a>).
<li>
A distance from the previous line equal to the maximum size of any <a data-link-type=dfn href=#grid-item title="grid items">grid items</a>
belonging to the column between these two lines.
<li>