-
Notifications
You must be signed in to change notification settings - Fork 709
/
Copy pathOverview.html
4022 lines (3285 loc) · 295 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>
<script>self = (typeof window !== 'undefined')
? window // if in browser
: (
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
? self // if in worker
: {} // if in node js
);
/**
* Prism: Lightweight, robust, elegant syntax highlighting
* MIT license http://www.opensource.org/licenses/mit-license.php/
* @author Lea Verou http://lea.verou.me
*/
var Prism = (function(){
// Private helper vars
var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
var _ = self.Prism = {
util: {
encode: function (tokens) {
if (tokens instanceof Token) {
return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
} else if (_.util.type(tokens) === 'Array') {
return tokens.map(_.util.encode);
} else {
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
}
},
type: function (o) {
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
},
// Deep clone a language definition (e.g. to extend it)
clone: function (o) {
var type = _.util.type(o);
switch (type) {
case 'Object':
var clone = {};
for (var key in o) {
if (o.hasOwnProperty(key)) {
clone[key] = _.util.clone(o[key]);
}
}
return clone;
case 'Array':
return o.slice();
}
return o;
}
},
languages: {
extend: function (id, redef) {
var lang = _.util.clone(_.languages[id]);
for (var key in redef) {
lang[key] = redef[key];
}
return lang;
},
// Insert a token before another token in a language literal
insertBefore: function (inside, before, insert, root) {
root = root || _.languages;
var grammar = root[inside];
var ret = {};
for (var token in grammar) {
if (grammar.hasOwnProperty(token)) {
if (token == before) {
for (var newToken in insert) {
if (insert.hasOwnProperty(newToken)) {
ret[newToken] = insert[newToken];
}
}
}
ret[token] = grammar[token];
}
}
return root[inside] = ret;
},
// Traverse a language definition with Depth First Search
DFS: function(o, callback, type) {
for (var i in o) {
if (o.hasOwnProperty(i)) {
callback.call(o, i, o[i], type || i);
if (_.util.type(o[i]) === 'Object') {
_.languages.DFS(o[i], callback);
} else if (_.util.type(o[i]) === 'Array') {
_.languages.DFS(o[i], callback, i);
}
}
}
}
},
highlightAll: function(async, callback) {
var elements = document.querySelectorAll('pre[class*="language-"], [class*="language-"] pre, pre[class*="lang-"], [class*="lang-"] pre');
for (var i=0, element; element = elements[i++];) {
_.highlightElement(element, async === true, callback);
}
},
highlightElement: function(element, async, callback) {
// Find language
var language, grammar, parent = element;
while (parent && !lang.test(parent.className)) {
parent = parent.parentNode;
}
if (parent) {
language = (parent.className.match(lang) || [,''])[1];
grammar = _.languages[language];
}
if (!grammar) {
return;
}
// Set language on the element, if not present
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
// Set language on the parent, for styling
parent = element.parentNode;
if (/pre/i.test(parent.nodeName)) {
parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
}
var code = element.textContent;
if(!code) {
return;
}
var env = {
element: element,
language: language,
grammar: grammar,
code: code
};
_.hooks.run('before-highlight', env);
if (async && self.Worker) {
var worker = new Worker(_.filename);
worker.onmessage = function(evt) {
env.highlightedCode = Token.stringify(JSON.parse(evt.data), language);
_.hooks.run('before-insert', env);
env.element.innerHTML = env.highlightedCode;
callback && callback.call(env.element);
_.hooks.run('after-highlight', env);
};
worker.postMessage(JSON.stringify({
language: env.language,
code: env.code
}));
}
else {
env.highlightedCode = _.highlight(env.code, env.grammar, env.language)
_.hooks.run('before-insert', env);
env.element.innerHTML = env.highlightedCode;
callback && callback.call(element);
_.hooks.run('after-highlight', env);
}
},
highlight: function (text, grammar, language) {
var tokens = _.tokenize(text, grammar);
return Token.stringify(_.util.encode(tokens), language);
},
tokenize: function(text, grammar, language) {
var Token = _.Token;
var strarr = [text];
var rest = grammar.rest;
if (rest) {
for (var token in rest) {
grammar[token] = rest[token];
}
delete grammar.rest;
}
tokenloop: for (var token in grammar) {
if(!grammar.hasOwnProperty(token) || !grammar[token]) {
continue;
}
var patterns = grammar[token];
patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
for (var j = 0; j < patterns.length; ++j) {
var pattern = patterns[j],
inside = pattern.inside,
lookbehind = !!pattern.lookbehind,
lookbehindLength = 0,
alias = pattern.alias;
pattern = pattern.pattern || pattern;
for (var i=0; i<strarr.length; i++) { // Don’t cache length as it changes during the loop
var str = strarr[i];
if (strarr.length > text.length) {
// Something went terribly wrong, ABORT, ABORT!
break tokenloop;
}
if (str instanceof Token) {
continue;
}
pattern.lastIndex = 0;
var match = pattern.exec(str);
if (match) {
if(lookbehind) {
lookbehindLength = match[1].length;
}
var from = match.index - 1 + lookbehindLength,
match = match[0].slice(lookbehindLength),
len = match.length,
to = from + len,
before = str.slice(0, from + 1),
after = str.slice(to + 1);
var args = [i, 1];
if (before) {
args.push(before);
}
var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias);
args.push(wrapped);
if (after) {
args.push(after);
}
Array.prototype.splice.apply(strarr, args);
}
}
}
}
return strarr;
},
hooks: {
all: {},
add: function (name, callback) {
var hooks = _.hooks.all;
hooks[name] = hooks[name] || [];
hooks[name].push(callback);
},
run: function (name, env) {
var callbacks = _.hooks.all[name];
if (!callbacks || !callbacks.length) {
return;
}
for (var i=0, callback; callback = callbacks[i++];) {
callback(env);
}
}
}
};
var Token = _.Token = function(type, content, alias) {
this.type = type;
this.content = content;
this.alias = alias;
};
Token.stringify = function(o, language, parent) {
if (typeof o == 'string') {
return o;
}
if (Object.prototype.toString.call(o) == '[object Array]') {
return o.map(function(element) {
return Token.stringify(element, language, o);
}).join('');
}
var env = {
type: o.type,
content: Token.stringify(o.content, language, parent),
tag: 'span',
classes: ['token', o.type],
attributes: {},
language: language,
parent: parent
};
if (env.type == 'comment') {
env.attributes['spellcheck'] = 'true';
}
if (o.alias) {
var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
Array.prototype.push.apply(env.classes, aliases);
}
_.hooks.run('wrap', env);
var attributes = '';
for (var name in env.attributes) {
attributes += name + '="' + (env.attributes[name] || '') + '"';
}
return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
};
if (!self.document) {
if (!self.addEventListener) {
// in Node.js
return self.Prism;
}
// In worker
self.addEventListener('message', function(evt) {
var message = JSON.parse(evt.data),
lang = message.language,
code = message.code;
self.postMessage(JSON.stringify(_.util.encode(_.tokenize(code, _.languages[lang]))));
self.close();
}, false);
return self.Prism;
}
// Get current script and highlight
var script = document.getElementsByTagName('script');
script = script[script.length - 1];
if (script) {
_.filename = script.src;
if (document.addEventListener && !script.hasAttribute('data-manual')) {
document.addEventListener('DOMContentLoaded', _.highlightAll);
}
}
return self.Prism;
})();
if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
}
;
Prism.languages.markup = {
'comment': /<!--[\w\W]*?-->/g,
'prolog': /<\?.+?\?>/,
'doctype': /<!DOCTYPE.+?>/,
'cdata': /<!\[CDATA\[[\w\W]*?]]>/i,
'tag': {
pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,
inside: {
'tag': {
pattern: /^<\/?[\w:-]+/i,
inside: {
'punctuation': /^<\/?/,
'namespace': /^[\w-]+?:/
}
},
'attr-value': {
pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,
inside: {
'punctuation': /=|>|"/g
}
},
'punctuation': /\/?>/g,
'attr-name': {
pattern: /[\w:-]+/g,
inside: {
'namespace': /^[\w-]+?:/
}
}
}
},
'entity': /\&#?[\da-z]{1,8};/gi
};
// Plugin to make entity title show the real entity, idea by Roman Komarov
Prism.hooks.add('wrap', function(env) {
if (env.type === 'entity') {
env.attributes['title'] = env.content.replace(/&/, '&');
}
});
;
Prism.languages.css = {
'comment': /\/\*[\w\W]*?\*\//g,
'atrule': {
pattern: /@[\w-]+?.*?(;|(?=\s*{))/gi,
inside: {
'punctuation': /[;:]/g
}
},
'url': /url\((["']?).*?\1\)/gi,
'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/g,
'property': /(\b|\B)[\w-]+(?=\s*:)/ig,
'string': /("|')(\\?.)*?\1/g,
'important': /\B!important\b/gi,
'punctuation': /[\{\};:]/g,
'function': /[-a-z0-9]+(?=\()/ig
};
if (Prism.languages.markup) {
Prism.languages.insertBefore('markup', 'tag', {
'style': {
pattern: /<style[\w\W]*?>[\w\W]*?<\/style>/ig,
inside: {
'tag': {
pattern: /<style[\w\W]*?>|<\/style>/ig,
inside: Prism.languages.markup.tag.inside
},
rest: Prism.languages.css
}
}
});
};
Prism.languages.css.selector = {
pattern: /[^\{\}\s][^\{\}]*(?=\s*\{)/g,
inside: {
'pseudo-element': /:(?:after|before|first-letter|first-line|selection)|::[-\w]+/g,
'pseudo-class': /:[-\w]+(?:\(.*\))?/g,
'class': /\.[-:\.\w]+/g,
'id': /#[-:\.\w]+/g
}
};
Prism.languages.insertBefore('css', 'ignore', {
'hexcode': /#[\da-f]{3,6}/gi,
'entity': /\\[\da-f]{1,8}/gi,
'number': /[\d%\.]+/g
});;
</script><style>/* http://prismjs.com/download.html?themes=prism&languages=clike */
/**
* prism.js default theme for JavaScript, CSS and HTML
* Based on dabblet (http://dabblet.com)
* @author Lea Verou
*/
code[class*="language-"],
pre[class*="language-"] {
color: black;
text-shadow: 0 1px white;
font-family: Consolas, Monaco, 'Andale Mono', monospace;
direction: ltr;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
text-shadow: none;
background: #b3d4fc;
}
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
code[class*="language-"]::selection, code[class*="language-"] ::selection {
text-shadow: none;
background: #b3d4fc;
}
@media print {
code[class*="language-"],
pre[class*="language-"] {
text-shadow: none;
}
}
/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: .5em 0;
overflow: auto;
}
:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #f5f2f0;
}
/* Inline code */
:not(pre) > code[class*="language-"] {
padding: .1em;
border-radius: .3em;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
color: slategray;
}
.token.punctuation {
color: #999;
}
.namespace {
opacity: .7;
}
.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
color: #905;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
color: #690;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
color: #a67f59;
background: hsla(0, 0%, 100%, .5);
}
.token.atrule,
.token.attr-value,
.token.keyword {
color: #07a;
}
.token.function {
color: #DD4A68;
}
.token.regex,
.token.important,
.token.variable {
color: #e90;
}
.token.important {
font-weight: bold;
}
.token.entity {
cursor: help;
}
</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" id=subtitle><span class=content>Editor’s Draft,
<span class=dt-updated><span class=value-title title=20141113>13 November 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><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><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><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><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><span><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>)</span><dt class=editor>Editors:<dd class=editor><div 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>)</div><dd class=editor><div 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>)</div><dd class=editor><div 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>)</div><dt>Former Editors:<dd><div 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>)</div><dd><div 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>)</div><dt>Issues list:<dd><span><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></span></dl></div>
<div data-fill-with=warning></div>
<p class=copyright data-fill-with=copyright><a href=http://www.w3.org/Consortium/Legal/ipr-notice#Copyright>Copyright</a> © 2014 <a href=http://www.w3.org/><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a href=http://www.csail.mit.edu/><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href=http://www.ercim.eu/><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>, <a href=http://www.keio.ac.jp/>Keio</a>, <a href=http://ev.buaa.edu.cn/>Beihang</a>), 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" 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" 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>.
<p>
This document is governed by the <a href=http://www.w3.org/2014/Process-20140801/>1 August 2014 W3C Process Document</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=#valdef-grid-template-rows-grid-template-columns-subgrid 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" id=contents><span class=content>Table of Contents</span></h2>
<div data-fill-with=table-of-contents role=navigation><ul class=toc role=directory><li><a href=#intro><span class=secno>1</span> <span class=content>
Introduction and Overview</span></a><ul class=toc><li><a href=#background><span class=secno>1.1</span> <span class=content>
Background and Motivation</span></a><li><a href=#adapting-to-available-space><span class=secno>1.2</span> <span class=content>
Adapting Layouts to Available Space</span></a><li><a href=#source-independence><span class=secno>1.3</span> <span class=content>
Source-Order Independence</span></a><li><a href=#grid-layering><span class=secno>1.4</span> <span class=content>
Grid Layering of Elements</span></a></ul><li><a href=#grid-concepts><span class=secno>2</span> <span class=content>
Grid Layout Concepts and Terminology</span></a><ul class=toc><li><a href=#grid-track-concept><span class=secno>2.1</span> <span class=content>
Grid Tracks and Cells</span></a><li><a href=#grid-line-concept><span class=secno>2.2</span> <span class=content>
Grid Lines</span></a><li><a href=#grid-area-concept><span class=secno>2.3</span> <span class=content>
Grid Areas</span></a></ul><li><a href=#grid-model><span class=secno>3</span> <span class=content>
Grid Containers</span></a><ul class=toc><li><a href=#grid-containers><span class=secno>3.1</span> <span class=content>
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</span></a><li><a href=#intrinsic-sizes><span class=secno>3.2</span> <span class=content>
Sizing Grid Containers</span></a></ul><li><a href=#grid-items><span class=secno>4</span> <span class=content>
Grid Items</span></a><ul class=toc><li><a href=#visibility-collapse><span class=secno>4.1</span> <span class=content>
Collapsed Grid Items: the <span class=property data-link-type=propdesc title=visibility>visibility</span> property</span></a><li><a href=#order-property><span class=secno>4.2</span> <span class=content>
Reordered Grid Items: the <span class=property data-link-type=propdesc title=order>order</span> property</span></a><li><a href=#static-position><span class=secno>4.3</span> <span class=content>
Static Position of Grid Container Children</span></a></ul><li><a href=#grid-definition><span class=secno>5</span> <span class=content>
The Explicit Grid</span></a><ul class=toc><li><a href=#track-sizing><span class=secno>5.1</span> <span class=content>
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</span></a><ul class=toc><li><a href=#named-lines><span class=secno>5.1.1</span> <span class=content>
Named Grid Lines: the ''(<span class=production data-link-type=type title="<custom-ident>"><custom-ident></span>*)'' syntax</span></a><li><a href=#repeat-notation><span class=secno>5.1.2</span> <span class=content>
Repeating Rows and Columns: the <span class=css data-link-type=maybe title=repeat()>repeat()</span> notation</span></a><li><a href=#fr-unit><span class=secno>5.1.3</span> <span class=content>
Flexible Lengths: the <span class=css>fr</span> unit</span></a><li><a href=#subgrids><span class=secno>5.1.4</span> <span class=content>
Subgrids: the <span class=css data-link-for=grid-template-rows data-link-type=maybe title=subgrid>subgrid</span> keyword</span></a><li><a href=#resolved-track-list><span class=secno>5.1.5</span> <span class=content>
Resolved Values</span></a></ul><li><a href=#grid-template-areas-property><span class=secno>5.2</span> <span class=content>
Named Areas: the <span class=property data-link-type=propdesc title=grid-template-areas>grid-template-areas</span> property</span></a><ul class=toc><li><a href=#implicit-named-lines><span class=secno>5.2.1</span> <span class=content>
Implicit Named Lines</span></a><li><a href=#implicit-named-areas><span class=secno>5.2.2</span> <span class=content>
Implicit Named Areas</span></a></ul><li><a href=#explicit-grid-shorthand><span class=secno>5.3</span> <span class=content>
Explicit Grid Shorthand: the <span class=property data-link-type=propdesc title=grid-template>grid-template</span> property</span></a></ul><li><a href=#implicit-grids><span class=secno>6</span> <span class=content>
The Implicit Grid</span></a><ul class=toc><li><a href=#auto-tracks><span class=secno>6.1</span> <span class=content>
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</span></a><li><a href=#grid-auto-flow-property><span class=secno>6.2</span> <span class=content>
<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</span></a></ul><li><a href=#grid-shorthand><span class=secno>7</span> <span class=content>
Grid Definition Shorthand: the <span class=property data-link-type=propdesc title=grid>grid</span> property</span></a><li><a href=#placement><span class=secno>8</span> <span class=content>
Placing Grid Items</span></a><ul class=toc><li><a href=#common-uses><span class=secno>8.1</span> <span class=content>
Common Patterns for Grid Placement</span></a><ul class=toc><li><a href=#common-uses-named-areas><span class=secno>8.1.1</span> <span class=content>
Named Areas</span></a><li><a href=#common-uses-numeric><span class=secno>8.1.2</span> <span class=content>
Numeric Indexes and Spans</span></a><li><a href=#common-uses-named-lines><span class=secno>8.1.3</span> <span class=content>
Named Lines and Spans</span></a><li><a href=#common-uses-auto-placement><span class=secno>8.1.4</span> <span class=content>
Auto Placement</span></a><li><a href=#common-uses-auto-sizing><span class=secno>8.1.5</span> <span class=content>
Auto Sizing Subgrids</span></a></ul><li><a href=#line-placement><span class=secno>8.2</span> <span class=content>
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</span></a><ul class=toc><li><a href=#grid-placement-errors><span class=secno>8.2.1</span> <span class=content>
Grid Placement Conflict Handling</span></a></ul><li><a href=#placement-shorthands><span class=secno>8.3</span> <span class=content>
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</span></a><li><a href=#abspos-items><span class=secno>8.4</span> <span class=content>
Absolutely-positioned Grid Items</span></a><li><a href=#auto-placement-algo><span class=secno>8.5</span> <span class=content>
Grid Item Placement Algorithm</span></a></ul><li><a href=#alignment><span class=secno>9</span> <span class=content>
Alignment</span></a><ul class=toc><li><a href=#auto-margins><span class=secno>9.1</span> <span class=content>
Aligning with <span data-link-for=margin data-link-type=value title=auto>auto</span> margins</span></a><li><a href=#row-align><span class=secno>9.2</span> <span class=content>
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</span></a><li><a href=#column-align><span class=secno>9.3</span> <span class=content>
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</span></a><li><a href=#grid-align><span class=secno>9.4</span> <span class=content>
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</span></a><li><a href=#z-order><span class=secno>9.5</span> <span class=content>
Z-axis Ordering: the <span class=property data-link-type=propdesc title=z-index>z-index</span> property</span></a><li><a href=#grid-baselines><span class=secno>9.6</span> <span class=content>
Grid Baselines</span></a></ul><li><a href=#layout-algorithm><span class=secno>10</span> <span class=content>
Track Sizing Algorithm</span></a><ul class=toc><li><a href=#algo-terms><span class=secno>10.1</span> <span class=content>
Definition of Terms for use in Calculating Grid Track Sizes</span></a><li><a href=#algo-overview><span class=secno>10.2</span> <span class=content>
Overall Sizing Algorithm</span></a><li><a href=#algo-init><span class=secno>10.3</span> <span class=content>
Initialize Track Sizes</span></a><li><a href=#algo-content><span class=secno>10.4</span> <span class=content>
Resolve Content-Based Track Sizing Functions</span></a><li><a href=#algo-grow-tracks><span class=secno>10.5</span> <span class=content>
Grow All Tracks To Their Max</span></a><li><a href=#algo-flex-tracks><span class=secno>10.6</span> <span class=content>
Process Flexible Tracks</span></a><ul class=toc><li><a href=#algo-find-fr-size><span class=secno>10.6.1</span> <span class=content>
Find the Size of an <span class=css>fr</span></span></a></ul></ul><li><a href=#pagination><span class=secno>11</span> <span class=content>
Fragmenting Grid Layout</span></a><ul class=toc><li><a href=#fragmentation-alg><span class=secno>11.1</span> <span class=content>
Sample Fragmentation Algorithm</span></a></ul><li><a href=#acks><span class=secno></span> <span class=content>
Acknowledgements</span></a><li><a href=#changes><span class=secno></span> <span class=content>
Changes</span></a><li><a href=#translated-algo><span class=secno></span> <span class=content>
Appendix A: Translated Layout Algorithm</span></a><li><a href=#conformance><span class=secno></span> <span class=content>
Conformance</span></a><ul class=toc><li><a href=#conventions><span class=secno></span> <span class=content>
Document conventions</span></a><li><a href=#conformance-classes><span class=secno></span> <span class=content>
Conformance classes</span></a><li><a href=#partial><span class=secno></span> <span class=content>
Partial implementations</span></a><li><a href=#experimental><span class=secno></span> <span class=content>
Experimental implementations</span></a><li><a href=#testing><span class=secno></span> <span class=content>
Non-experimental implementations</span></a></ul><li><a href=#references><span class=secno></span> <span class=content>References</span></a><ul class=toc><li><a href=#normative><span class=secno></span> <span class=content>Normative References</span></a><li><a href=#informative><span class=secno></span> <span class=content>Informative References</span></a></ul><li><a href=#index><span class=secno></span> <span class=content>Index</span></a><li><a href=#property-index><span class=secno></span> <span class=content>Property Index</span></a><li><a href=#issues-index><span class=secno></span> <span class=content>Issues Index</span></a></ul></div>
<main>
<h2 class="heading settled" data-level=1 id=intro><span class=secno>1. </span><span class=content>
Introduction 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" 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" 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>
<div class=example>
<pre class=lang-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 }
</pre>
<pre class=lang-markup>
<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>
</div>
<h3 class="heading settled" data-level=1.3 id=source-independence><span class=secno>1.3. </span><span class=content>
Source-Order 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>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>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;