-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathnew.src.html
2878 lines (2372 loc) · 104 KB
/
new.src.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 public '-//W3C//DTD HTML 4.01//EN'
'http://www.w3.org/TR/html4/strict.dtd'>
<html lang="en">
<head profile="http://www.w3.org/2006/03/hcard">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS Grid Template Module</title>
<link rel="stylesheet" type="text/css" href="../default.css">
<link rel="stylesheet" type="text/css"
href="https://www.w3.org/StyleSheets/TR/W3C-[STATUS].css">
<style type="text/css">
.example .visible {border: thin dotted silver}
/* delete this block when you've cleared out all the .replaceme elements */
.replaceme {
border: solid red;
padding: 0 0.5em;
margin: 0 0.1em;
background: yellow;
color: green;
}
.replaceme:before {
content: "FIXME(";
color: black;
}
.replaceme:after {
content: ")";
color: black;
}
</style>
</head>
<div class="head">
<!--logo-->
<h1>CSS Grid Template Module</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE]</h2>
<dl>
<dt>This version:
<dd><a href="[VERSION]">https://www.w3.org/TR/[YEAR]/ED-css3-grid-template-[CDATE]/</a>
<dt>Latest version:
<dd><a href="https://www.w3.org/TR/[SHORTNAME]/">https://www.w3.org/TR/[SHORTNAME]/</a>
<dt>Editor's draft:
<dd><a href="https://drafts.csswg.org/[SHORTNAME]/">https://drafts.csswg.org/[SHORTNAME]/</a>
<dt>Previous version:
<dd><a href="http://www.w3.org/PreviousVersionURI">
http://www.w3.org/PreviousVersionURI</a>
<dt>Issues List:</dt>
<dd><a href="http://www.w3.org/Style/CSS/Tracker/products/FIXME">http://www.w3.org/Style/CSS/Tracker/products/FIXME</a>
<dt>Discussion:</dt>
<dd><a href="http://lists.w3.org/Archives/Public/www-style/">www-style@w3.org</a> with subject line “<kbd>[<!---->[SHORTNAME]] <var>… message topic …</var></kbd>”
<dt>Editors:
<dd class=vcard><span class=fn>[editor1 name]</span>,
<span class=org>[affiliation (opt.)]</span>,
<span class=email>[email address (opt.)]</span>
<dd class=vcard><span class=fn>[editor2 name]</span>,
<span class=org>[affiliation (opt.)]</span>,
<span class=email>[email address (opt.)]</span>
</dl>
<!--copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id="abstract">Abstract</h2>
<p>CSS is a language for describing the rendering of structured documents
(such as HTML and XML) on screen, on paper, in speech, etc. This module
contains the features of CSS level 3 relating to <var class="replaceme">DESCRIBE HERE</var>.
It includes and extends the functionality of CSS level 2 [[!CSS21]],
which builds on CSS level 1 [[CSS1]].
The main extensions compared to level 2 are <var class="replaceme">SUMMARIZE HERE</var>.
<h2 class="no-num no-toc" id="status">Status of this document</h2>
<!--status-->
<p>The following features are at risk: …
<p class=issue>Leave for next level or different module: chaining
regions, page templates, repeat (automatically add) columns and rows,
style fragments of elements that are in a certain slot (region-based
styling).
<h2 class="no-num no-toc" id="contents">
Table of contents</h2>
<!--toc-->
<h2 id="intro">
Introduction</h2>
<p><em>This section is not normative.</em>
<p class="issue">Merge introductory text, which right now is simply
concatenated between Grid and Template.</p>
<div class=sidefigure>
<p><img src="diagram.png" alt="Image: four elements move to four slots
in a template" longdesc="diagram.desc">
<p class=caption>Four slots, called a, b, c and d, each receive a
part of a document
</div>
<p class=mtb>The styling of a Web page, a form or a graphical user
interface can roughly be divided in two parts: (1) defining the
overall “grid” of the page or window and (2) specifying the fonts,
indents, colors, etc., of the text and other objects. The two are not
completely separate, of course, because indenting or coloring a text
influences the perceived grid as well. Nevertheless, when one
separates the parts of a style that should change when the window gets
bigger from the parts that stay the same, one often finds that the
grid changes (room for a sidebar, extra navigation bar, big margins,
larger images…), while fonts, colors, indents, numbering styles, and
many other things don't have to change, until the size of the window
becomes extreme.
<p>The properties in this specification work by associating a
<i>layout grid</i> with an element. Rather than letting an element
lay out its descendants in their normal order as inline text or as
blocks of text (the policies available in CSS level 1), the
policy defined in this module gives an element an invisible grid for
aligning selected descendant elements.
<p>Because layouts on the Web have to adapt to different window and
paper sizes, the rows and columns of the grid can be made fixed or
flexible in size.
<p>The typical use cases for these properties include:
<ul>
<li>Complex Web pages, with multiple navigation bars in fixed
positions, areas for advertisements, etc.
<li>Complex forms, where the alignment of labels and form fields may
be easier with the properties of this module than with the
properties for tables and margins.
<li>GUIs, where buttons, toolbars, labels, icons, etc., are aligned
in complex ways and have to stay aligned (and not wrap, for example)
when the window is resized.
</ul>
<p>Grid-based positioning is an alternative to absolute positioning,
which, like absolute positioning, is especially useful for aligning
elements that don't have simple relationships in the source
(parent-child, ancestor-descendant, immediate sibling). But in
contrast to absolute positioning, the elements are not positioned with
the help of horizontal and vertical coordinates, but by mapping them
into slots in a table-like template. The relative size and alignment
of elements is thus governed implicitly by the rows and columns of the
template.
<p>The mapping is done with the 'position' property, which specifies
in this case into which slot of the template the element goes. The
template itself is specified on the 'grid-template' property of some
ancestor of the elements to remap.
<div class=example>
<p>In this example, the four children of an element are assigned to
four slots (called a, b, c and d) in a 2×2 template. (All mark-up
examples in this specification are HTML fragments, unless otherwise
stated.)
<div class=sidefigure>
<p><img src="aapje.png" alt="Image: sample rendering" longdesc="aapje.desc">
<p class=caption>Each element occupies one slot. In this template,
all slots have the same size.
</div>
<pre>
<!-- --><style type="text/css">
<!-- --> dl { grid: "ab"
<!-- --> "cd" }
<!-- --> #sym1 { position: slot(a) }
<!-- --> #lab1 { position: slot(b) }
<!-- --> #sym2 { position: slot(c) }
<!-- --> #lab2 { position: slot(d) }
<!-- --></style>
<!-- --><dl>
<!-- --> <dt id=sym1>A
<!-- --> <dd id=lab1>A is een aapje
<!-- --> <dt id=sym2>B
<!-- --> <dd id=lab2>B is de bakker
<!-- --></dl>
</pre>
</div>
<div class=example>
<p>Templates can also help with device-independence. This example uses
Media Queries [[MEDIAQ]] to change the overall layout of a page from
3-column layout for a wide screen to a 1-column layout for a narrow
screen. It assumes the page has been marked-up with logical sections
with IDs.
<pre>
<!-- -->@media all
<!-- -->{
<!-- --> body { grid: "aaa"
<!-- --> "bcd" }
<!-- --> #head { position: slot(a) }
<!-- --> #nav { position: slot(b) }
<!-- --> #adv { position: slot(c) }
<!-- --> #body { position: slot(d) }
<!-- -->}
<!-- -->@media all and (max-width: 500px)
<!-- -->{
<!-- --> body { grid: "a"
<!-- --> "b"
<!-- --> "c" }
<!-- --> #head { position: slot(a) }
<!-- --> #nav { position: slot(b) }
<!-- --> #adv { display: none }
<!-- --> #body { position: slot(c) }
<!-- -->}</pre>
</div>
<div class=example>
<p>Elements can be positioned this way, but not made to overlap,
unless with negative margins. Here is how the <a
href="http://www.csszengarden.com/?cssfile=/026/026.css&page=0">
“zunflower” design</a> of the Zen Garden could be done:
<pre>
<!-- -->#container { grid: "abc" }
<!-- -->#intro { position: (a); margin-right: -2em; box-shadow: 0.5em 0.5em 0.5em }
<!-- -->#supportingText { position: slot(b); box-shadow: 0.5em 0.5em 0.5em }
<!-- -->#linkList { position: slot(c) }</pre>
</div>
<div class=example>
<p>Template-based positioning borrows some concepts from table layout,
in particular the idea of aligning elements in rows and columns, so
that they constrain each other's size. But there are also differences.
This example shows some of them. Assume this document fragment:
<pre>
<!-- --><div class=group>
<!-- --> <div>aa aa aa aa aa aa</div>
<!-- --> <div>bbb</div>
<!-- --> <div class=menu>ccccc</div>
<!-- --></div></pre>
<p>We can lay it out as three columns, as the following illustrations
show. The style sheet would contain the following.
<pre>
<!-- -->.group {display: table}
<!-- -->.group > div {display: table-cell}
</pre>
<div class=figure>
<p><img src="table1.png" alt="[Three unequal cells]" longdesc="table1.desc">
<p class=caption>Example of rendering with a table.
</div>
<p>We can also use a template, in which case the style sheet would
contain this:
<pre>
<!-- -->.group {grid: "abc"}
<!-- -->.group > div {position: slot(a)}
<!-- -->.group > div + div {position: slot(b)}
<!-- -->.group > div + div + div {position: slot(c)}
</pre>
<p>By default, the table is as wide as needed to fit its contents. To
make sure it is as wide as its containing block, we need to add
<pre>.group {display: table; width: 100%}</pre>
<p>That is not needed for the template, but, on the other hand, if we
want the template to fit its contents, we would need to say so:
<pre>.group {grid: "abc"; width: fit-content}</pre>
<p>(See [[!CSS3BOX]] for the definition of the 'width' property.) The
columns of the template are by default all the same size. The columns
of the table satisfy certain constraints, but the exact size is not
defined. We can make them all the same by adding a rule (see
[[!CSS3TBL]]):
<pre>.group {display: table; width: 100%; table-layout: fixed}</pre>
<div class=figure>
<p><img src="table2.png" alt="[Three equal cells]" longdesc="table2.desc">
<p class=caption>Example of rendering with equal columns.
</div>
<p>In both styles, we can set a column to a certain size:
<pre>div.menu {width: 3em}</pre>
<p>resp.,
<pre>.group {grid: "abc" * * 3em}</pre>
<div class=figure>
<p><img src="table3.png" alt="[Two equal cells, third is 3em wide]"
longdesc="table3.desc">
<p class=caption>Example of rendering with a fixed third column and
the other two columns of equal width.
</div>
<p>If there is an unknown number of columns (children of the div.group
element), the style sheet for the table model will automatically take
them into account. The style sheet for the template model, however,
creates a template of exactly three columns and can't handle tables
with an unknown number of columns. The extra elements will be added
into the default slot (in this case the ''a'' slot).
<p>In both models, elements can have borders, but only in the table
model can borders be collapsed, which makes setting borders a little
easier in the table model:
<pre>
<!-- -->.group {display: table; border-collapse: collapse}
<!-- -->.group > div {border: solid}</pre>
<p>resp.,
<pre>
<!-- -->.group > div {border: solid; border-left: none}
<!-- -->.group > div:first-child {border-left: solid}
</pre>
<p>In the template model, the order of the elements is explicit, and
thus it is possible to reverse the order of the columns:
<pre>
<!-- -->.group > div {position: slot(c)}
<!-- -->.group > div + div {position: slot(b)}
<!-- -->.group > div + div + div {position: slot(a)}
</pre>
<div class=figure>
<p><img src="table4.png" alt="[Different contents for the cells]"
longdesc="table4.desc">
<p class=caption>Example of rendering with the contents of the three
columns reversed: the third element is shown in the first slot and
the first element in the third slot.
</div>
<p>In the table model, the order of the rows and columns is given by
the document source and thus can't be changed.
</div>
<div class=example>
<p>This example shows a way to move notes to the end of a section.
“Notes” in this example refers to elements in HTML with a class of
“note”. A fragment of HTML such as
<pre>
<!-- --><div class=section>
<!-- --> <p>The balubious coster of the fifth secter<span
<!-- --> class=note> The sixth secter coster is a difter
<!-- --> manon.</span> of The Rollow Carpug mentizes a costernica.
<!-- --> <p>…
<!-- --></div></pre>
<p>with this style sheet
<pre>
<!-- -->div.section {
<!-- --> grid: "*" available
<!-- --> "F" available}
<!-- -->.note {
<!-- --> position: slot(F);
<!-- --> content: counter(note) ".\A0" contents;
<!-- --> counter-increment: note;
<!-- --> font-size: smaller}
<!-- -->.note::before {
<!-- --> content: counter(note);
<!-- --> position: slot(*);
<!-- --> vertical-align: super;
<!-- --> font-size: larger}</pre>
<p>results in a rendering similar to this:
<div class=figure>
<p><img src="footnotes.png" alt="Same text, with the SPAN replaced by
“(1)” and its content moved to the end." longdesc="footnotes.desc">
<p class=caption>Rendering of a text with footnotes.
</div>
</div>
<h3 id="grid-intro">
Introduction to Grids</h3>
<h3 id="background">
Background</h3>
<div class="sidefigure">
<img class="figure" alt="FIXME" src="images/basic-form.png" />
<p class="caption">Application layout example requiring horizontal
and vertical alignment.</p>
</div>
<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>The layout capabilities of the Grid address these problems. The Grid
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 referencing the <a href="#grid-line">Grid Line</a>s
between the columns and rows, or by defining and referencing a
<a href="#grid-cell">Grid Slot</a>, which is a rectangular space covering
an intersection of columns and rows. Figure 1 illustrates a basic layout
which can be achieved with the Grid.
<h3 id="space-adapt">Adapting Layouts to Available Space</h3>
<div class="sidefigure">
<p><img alt="FIXME" src="images/game-smaller.png" />
<p class="caption">Five grid items arranged according to content size
and available space.</p>
</div>
<div class="sidefigure">
<p><img alt="FIXME" src="images/game-larger.png" />
<p class="caption">Growth in the grid due to an increase in available
space.</p>
</div>
<p>The <i>grid element</i> 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:
<ul>
<li>The stats area always appears immediately under the game title.</li>
<li>The game board appears to the right of the stats and title.</li>
<li>The top of the game title and the game board should always align.</li>
<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>
<li>The score area should align into the column created by the game and stats area, while the controls are centered under the board.</li>
</ul>
<p>As an alternative to using script to control the absolute position,
width, and height of all elements, the author can use the
<i>grid element</i>, as shown in Figure 3.
The following example shows how an author might achieve all the sizing,
placement, and alignment rules declaratively.
<p>Note that there are multiple ways to specify the structure of the
<a href="#grid-element">Grid</a> and to position and size
<i>grid items</i>, each optimized for different scenarios.
This example illustrates one that an author may use to define the position
and space for each <i>grid item</i> using the
'grid-rows' and 'grid-columns' properties of the
<i>grid element</i>,
and the 'grid-row' and 'grid-column' properties on each
<i>grid item</i>.
</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-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-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; grid-row-align: start }
#board { grid-column: 2; grid-row: 1; grid-row-span: 2 }
#controls { grid-column: 2; grid-row: 3; grid-column-align: 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 id="source-independence">
Source Independence</h3>
<div class="sidefigure">
<p><img alt="FIXME" src="images/game-portrait.png" />
<p class="caption">An arrangement suitable for "portrait" orientation.</p>
</div>
<div class="sidefigure">
<p><img alt="FIXME" src="images/game-landscape.png" />
<p class="caption">An arrangement suitable for "landscape" orientation.</p>
</div>
<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 the CSS markup for the
<i>grid element</i> with
<a href="https://www.w3.org/TR/css3-mediaqueries/">media queries</a>
[[MEDIAQ]], the author is able to use the same semantic markup, but
rearranged independent of its source order, to achieve the desired layout
in both orientations.
<p>The following example leverages the <a href="#grid-element">Grid</a>'s
ability to name the space which will be occupied by a
<i>grid item</i>. This allows the author to avoid
rewriting rules for <i>grid items</i> as the
<a href="#grid-element">Grid</a>'s definition changes.
<pre class="example"><style type="text/css">
@media (orientation: portrait) {
#grid {
display: grid;
/* The rows, columns and cells of the grid are defined visually using the grid-template property. */
/* Each string is a row, and each letter a cell. The max number of letters in any one string determines */
/* the number of columns. */
grid-template: "ta"
"sa"
"bb"
"cc";
/* Columns and rows created with the template property can be assigned a sizing function with the */
/* grid-columns and grid-rows properties. */
grid-columns: auto minmax(min-content, 1fr);
grid-rows: auto auto minmax(min-content, 1fr) auto
}
}
@media (orientation: landscape) {
#grid {
display: grid;
/* Again the template property defines cells of the same name, but this time positioned differently */
/* to better suit a landscape orientation. */
grid-template: "tb"
"ab"
"sc";
grid-columns: auto minmax(min-content, 1fr);
grid-rows: auto minmax(min-content, 1fr) auto
}
}
/* The grid-cell property places a grid item into named region (cell) of the grid. */
#title { grid-cell: "t" }
#score { grid-cell: "s" }
#stats { grid-cell: "a" }
#board { grid-cell: "b" }
#controls { grid-cell: "c" }
</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 id=accessibility>
A note on the accessibility of content reordering</h3>
<p><em>(This section is not normative.)</em>
<p>The facilities in this specification allow elements from a document
to be displayed in a visual order that is to a large extent
independent of the order in the document. That may have both positive
and negative effects on accessibility. The positive aspect is that it
allows the content in the document to be kept in logical order, so
that the document is as functional as possible without the style sheet
and on media where the style sheet doesn't apply. A negative aspect is
that a document that has a defined tab order (the order in which
elements get the focus when the tab-key is pressed) will show on the
screen with a tab order unrelated to the visual order. It may be
necessary to use the keyboard control features of the CSS Basic User
Interface module [[CSS3UI]] to ensure that the tab navigation follows
the visual order, or to refrain from positioning semantically related
elements in different parts of a template.
<p>The following two requirements from the Web Content Accessibility
Guidelines (WCAG) 2.0 [[WCAG20]] are particularly relevant. See that
specification for more information.
<blockquote>
<p><a
href="https://www.w3.org/TR/2008/REC-WCAG20-20081211/#content-structure-separation-sequence"
><strong>1.3.2 Meaningful Sequence:</strong></a> When the sequence in
which content is presented affects its meaning, a <a
href="https://www.w3.org/TR/2008/REC-WCAG20-20081211/#correct-reading-sequencedef"
>correct reading sequence</a> can be <a
href="https://www.w3.org/TR/2008/REC-WCAG20-20081211/#programmaticallydetermineddef
">programmatically determined.</a> (Level A)
</blockquote>
<blockquote>
<p><a
href="https://www.w3.org/TR/2008/REC-WCAG20-20081211/#navigation-mechanisms-focus-order"
><strong>2.4.3 Focus Order:</strong></a> If a <a
href="https://www.w3.org/TR/2008/REC-WCAG20-20081211/#webpagedef" >Web
page</a> can be <a
href="https://www.w3.org/TR/2008/REC-WCAG20-20081211/#nav-seqdef"
>navigated sequentially</a> and the navigation sequences affect
meaning or operation, focusable components receive focus in an order
that preserves meaning and operability. (Level A)
</blockquote>
<h3 id="intro-layering">
Grid Layering of Elements</h3>
<div class="sidefigure">
<p><img alt="FIXME" src="images/control-layering-and-alignment.png" />
<p class="caption">A control composed of layered HTML elements.</p>
</div>
<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 fraction-sized columns.
<p>Prior to the <i>grid element</i>, 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 the <i>grid element</i>,
the author can instead limit script usage to handling mouse events on the
thumb, which snaps to various positions along the track as the
'grid-columns' property of the <i>grid element</i> is
updated.
<pre class="example"><style type="text/css">
#grid {
display: grid;
/* The grid-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-columns:
"start" auto
"track-start" 0.5fr
"thumb-start" auto
"fill-split" auto
"thumb-end" 0.5fr
"track-end" auto
"end";
}
/* Grid-column and grid-row accept a starting and optional endling line. Below the lines are referred to by name. */
/* Beyond any semantic advantage, the names also allow the author to avoid renumbering the grid-row and column */
/* properties of the grid items. This is similar to the concept demonstrated in the prior example with the */
/* grid-template property during orientation changes, but grid lines can also work with layered grid items that */
/* have overlapping cells of different shapes like the thumb and track parts in this example. */
#lower-label { grid-column: "start" }
#track { grid-column: "track-start" "track-end"; grid-row-align: center }
#upper-label { grid-column: "track-end"; }
/* Fill parts are drawn above the track so set z-index to 5. */
#lower-fill { grid-column: "track-start" "fill-split"; grid-row-align: center; z-index: 5 }
#upper-fill { grid-column: "fill-split" "track-end"; grid-row-align: center; 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>
<h3 id="placement">
Module interactions</h3>
<p class="replaceme">Explain, normatively, how this module affects the definition of CSS.</p>
<p>This module replaces and extends the <var class="replaceme">SUMMARIZE HERE</var>
features defined in [[!CSS21]] sections <var class="replaceme">W.X and Y.Z</var>.
<p>See [[!CSS3PAGE]] for the definition of <a
href="https://www.w3.org/TR/css3-multicol/#multi-column-element"
><dfn>multi-column element.</dfn></a>
<p>[[!CSS3-WRITING-MODES]] defines the <dfn>writing-mode</dfn>
property, which defines when elements have a <dfn>vertical writing
mode</dfn> (text lines are vertical) or a <dfn>horizontal writing
mode</dfn> (text lines are horizontal). For brevity, we refer to the
former as a <dfn title="vertical|vertical element" >vertical
element</dfn> and to the latter as a <dfn
title="horizontal|horizontal element" >horizontal element.</dfn>
<p>[[!CSS3BOX]] defines the intrinsic sizes of boxes.
<p>Following [[!CSS3-WRITING-MODES]] and [[!CSS3BOX]], we define the
<dfn>inline dimension</dfn> of a box, element or slot as meaning
either its width or height, depending on whether it is
<em>horizontal</em> or <em>vertical,</em> respectively. And
likewise: the <dfn>block dimension</dfn> of a box, element or slot
<em>at a given inline dimension</em> is its size in the
perpendicular dimension.
<p>'Direction' is defined in [[!CSS21]].
<h3 id="values">
Values</h3>
<p>This specification follows the
<a href="https://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from [[!CSS21]]. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
Other CSS modules may expand the definitions of these value types: for
example [[CSS3COLOR]], when combined with this module, expands the
definition of the <color> value type as used in this specification.</p>
<p>In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the
<a href="https://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">inherit</a>
keyword as their property value. For readability it has not been repeated
explicitly.
<h2 id="terminology">
Core Concepts of the Grid</h2>
<div class="sidefigure">
<img class="figure" alt="FIXME" src="images/grid-concepts.png">
<p class="caption">A diagram illustrating the relationship between
the <i>grid element</i> and its Tracks, Lines,
Cells and Items.</p>
</div>
<p>A <dfn id="grid-element">grid element</dfn> is declared in markup by
setting the display property of an element to ''grid'' or ''inline-grid''.
<!--
Child elements of the Grid are termed <a href="#grid-item">grid items</a>
and may be positioned and sized by the <i>grid element</i>
by leveraging the following logical concepts:
<ul>
<li><a href="#grid-track">Grid Track</a>s</li>
<li><a href="#grid-line">Grid Line</a>s</li>
<li><a href="#slot">Slot</a>s</li>
</ul>
-->
<p>
Figure 7 illustrates the relationship between these concepts and the markup
in the subsections that follow produce the result shown in the figure.
</p>
<p><dfn>Grid track</dfn> is the generic name in this specification
for a row or column in a grid. Grid tracks are defined with the
properties 'grid-rows' (to define rows) and 'grid-columns' (to
define columns) on the <i>grid element</i>. Each track is defined by
declaring a list of sizes, one size for each track. <!-- Tracks
define the space between <a href="#grid-line">Grid Line</a>s. -->
<pre class="example"><style type="text/css">
#grid {
grid-columns: 150px 1fr; /* two columns */
grid-rows: 50px 1fr 50px /* three rows */
}
</style></pre>
<p><dfn>Grid line</dfn> is the term in this specification for the
vertical edges of columns and the horizontal edges of rows. If there
are <var>N</var> columns, their edges are numbered from 1 (the
leftmost edge of the first column) to <var>N</var>+1 (the rightmost
edge of the last column. Analogously for the edges of the rows.
<!--
<p>The following two examples create three column <i>Grid Lines</i>
and four row <i>Grid Lines</i>. The first example demonstrates how
an author would refer to the <a href="#grid-line">Grid Line</a>s
using <a href="#grid-line">Grid Line</a> numbers. The second example
uses explicitly named <a href="#grid-line">Grid Line</a>s.
<pre class="example"><style type="text/css">
#grid {
display: grid;
grid-columns: 150px 1fr;
grid-rows: 50px 1fr 50px
}
#item1 { grid-column: 2; grid-row: 1 4 }
</style></pre>
<pre class="example"><style type="text/css">
/* equivalent layout to the prior example, but using named lines */
#grid {
display: grid;
grid-columns: 150px "item1-start" 1fr "item1-end";
grid-rows: "item1-start" 50px 1fr 50px "item1-end"
}
#item1 {
grid-column: "item1-start" "item1-end";
grid-row: "item1-start" "item1-end"
}
</style></pre>
-->
<p>A <dfn>grid cell</dfn> is the intersection of a row and a
column. A grid with <var>N</var> columns and <var>M</var> rows has
<var>N</var>*<var>M</var> cells.
<!-- The term “slot” is defined under 'grid-template' -->
<!--
are the logical space used to lay out
one or more <i>grid items</i>.
<i>slots</i> can be defined explicitly using the 'grid-template'
property, or anonymously by referencing a region of the Grid using the
'grid-row' and 'grid-column' properties on a <i>grid item</i>.
<p>Whether a <i>slot</i> is created explicitly or implicitly, there
is no difference in the layout or drawing order of the
<i>grid items</i> which are associated with that
<i>slot</i>.
<pre class="example"><style type="text/css">
/* using the template syntax */
#grid {
display: grid;
grid-template: "ad"
"bd"
"cd";
grid-columns: 150px 1fr;
grid-rows: 50px 1fr 50px
}
#item2 { position: slot(b) }
#item3 { position: slot(b) }
/* Align items 2 and 3 at different points in the slot "b". */
/* By default, Grid Items are stretched to fit their slot */
/* and these items would layer one over the other. */
#item2 { grid-row-align: start }
#item3 { grid-column-align: end; grid-row-align: end }</style></pre>
-->
<h2 id=display>
Declaring a grid template</h2>
<p>An element is a <dfn>grid element</dfn> (i.e., it defines a grid
for its descendants) if its 'display' value is ''grid'' or ''inline-grid''.
<p>The <dfn>grid ancestor</dfn> of an element is the nearest
ancestor that is a grid element.
<table class="propdef">
<tr>
<th>Name:
<td><dfn>display</dfn>
<tr>
<th><a href="#values">Value</a>:
<td>… | grid | inline-grid
</table>
<p>This module adds the ''grid'' and ''inline-grid'' values to the 'display'
property [[CSS21]], as defined below:
<dl>
<dt><dfn id="value-def-display--grid">''grid''</dfn></dt>
<dd>A value of grid causes an element to display as a block-level
<i>grid element</i>.</dd>
<dt><dfn id="value-def-display-inline-grid">''inline-grid''</dfn></dt>
<dd>A value of inline-grid causes an element to display as an
inline-level <i>grid element</i>.</dd>
</dl>
<div class="issue">
<p>Should grid elements be created automatically without using
'display'? On the one hand, this (a) is not consistent with how flex
boxes are created and (b) could create some confusing dynamics
(e.g., setting ''display: table'' or 'display: flexbox' removes any
grid, but setting 'display: table-cell' or 'display: list-item'
keeps the grid); but (1) requires only one instead of two properties
to create a grid element, (2) allows other block container elements
(such as table cells, table captions, list items, flex
items…) to contain a grid, without extra keywords for
'display' ('table-cell-grid', 'list-item-grid'…), and (3) is
consistent with how <a
href="https://www.w3.org/TR/css3-multicol/#multi-column-element"
>multicolumn elements</a> are created.
<p>Proposed text:
<p>An element is a <dfn>grid element</dfn> (i.e., it defines a grid
for its descendants) if it generates a
a <a href="https://www.w3.org/TR/CSS21/visuren.html#block-boxes" >block
container box</a> [[!CSS21]] and one or more of the following is true:
<ul>
<li>The element's 'grid-template' is not ''none''.
<li>The element's 'grid-rows' is not ''auto''.
<li>The element's 'grid-columns' is not ''auto''.
</ul>
<p>These properties are defined below.
</div>
<p class=note>Block containers are, informally, elements that can have
block elements as children, such as blocks, inline blocks or table
cells, but not inline elements or replaced elements.
<p>The <dfn>number of columns</dfn> of a <span>grid element</span>
is defined as follows:
<ol>
<li>If 'grid-template' is not 'none', it determines the number of
columns.
<li>Otherwise, if 'grid-columns' is not 'auto', the number of
columns is equal to the number of <var><track-size></var>
values in 'grid-columns'.
<li>Otherwise, the grid has one column.
</ol>
<p>The <dfn>number of rows</dfn> of a <span>grid element</span> is
defined as follows:
<ol>
<li>If 'grid-template' is not 'none', it determines the number of
rows.
<li>Otherwise, if 'grid-rows' is not 'auto', the number of rows is
equal to the number of <var><track-size></var> values in
'grid-rows'.
<li>Otherwise, the grid has one row.
</ol>
<div class=issue>
<p>Alternative definition:
<p>The number of columns is the number of
<var><track-size></var> values in 'grid-columns' or the number
of columns in 'grid-template', whichever is larger. (A value of
''none'' in this case means zero columns.)
<p>The number of rows is the number of <var><track-size></var>
values in 'grid-rows' or the number of rows in 'grid-template',
whichever is larger. (A value of ''none'' in this case means zero
rows.)
</div>
<p class=issue>What if an element has both 'columns' and
'grid-template', is it a grid element or a column element? (or do the
columns apply to the default slot?)
<p class=issue>Use 'fr' unit (as in css3-grid-align) instead of '*' (as
in css3-layout).
<h3 id="grid-lines-tracks">
Grid Lines and Tracks</h3>
<div class="sidefigure">
<img class="figure" alt="Image: Grid Lines." src="images/grid-lines.png">
<p class="caption">Grid Lines.</p>
</div>
<p><i>grid element</i>s use
<a href="#grid-line">Grid Line</a>s to divide their space.
There are two sets of <a href="#grid-line">Grid Line</a>s: one set
defined by the columns parallel to the
<a href="https://www.w3.org/TR/css3-writing-modes/#block-flow-dimensions">block flow dimension</a>,