-
Notifications
You must be signed in to change notification settings - Fork 708
/
Copy pathOverview.src.html
4548 lines (3631 loc) · 155 KB
/
Overview.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">
<html lang=en>
<head
profile="http://microformats.org/profile/hcard http://microformats.org/wiki/rel-license">
<meta content="text/html; charset=utf-8" http-equiv=content-type>
<title>CSS Template Layout Module</title>
<link href="../default.css" rel=stylesheet type="text/css">
<style type="text/css">
/* Just in case an incorrect max-width occurs in default.css */
body {max-width: none !important}
/* The TR postprocessor already inserted quotes: */
.css::before, .property::before, .descriptor::before {content: none}
.css::after, .property::after, .descriptor::after {content: none}
.prod { font-family: inherit; font-size: inherit }
pre.prod { white-space: pre-wrap; margin: 1em 0 1em 2em }
code { font-size: inherit; }
.example .visible {border: thin dotted silver}
</style>
<link rel=stylesheet href="https://www.w3.org/StyleSheets/TR/W3C-MO.css">
<body class=h-entry>
<div class=head><!--logo-->
<h1 class=p-name>CSS Template Layout Module</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE: 3 August 2004]</h2>
<dl>
<dt>This version:
<dd><a class=u-url href="[VERSION]">[VERSION]</a>
<dt>Latest version:
<dd><a href="[LATEST]">https://www.w3.org/TR/css-template-3/</a>
<dt>Previous version:
<dd><a href="https://www.w3.org/TR/2015/NOTE-css-template-3-20150326/"
>https://www.w3.org/TR/2015/NOTE-css-template-3-20150326/</a>
<dt>Feedback:
<dd><a
href="mailto:www-style@w3.org?subject=%5Bcss3-layout%5D%20feedback"
>www-style@w3.org</a> with subject line “[css-template-3]
<var>… message topic …</var>” (<a
rel="discussion"
href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)
<dt>Editors:
<dd class="p-author h-card vcard"><span class="p-name fn">Bert
Bos</span> (<span class="p-org org h-org">W3C</span>) <a
class="u-email email" href="mailto:bert@w3.org"
rel=author>bert@w3.org</a>
<dd class="p-author h-card vcard"><span class="p-name fn">César
Acebal</span> (<span class="p-org org h-org">University of
Oviedo</span>)
<dt>Editors' draft:
<dd><a href="https://drafts.csswg.org/css-template/"
>https://drafts.csswg.org/css-template/</a>
</dl>
<!--copyright-->
<hr title="Separator for header">
</div>
<!--=================================================================-->
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<div class=sidefigure>
<p><img alt="Image: four elements move to four slots in a template"
longdesc=diagram.desc src=diagram.png>
<p class=caption>Above: a typical Web page. Below: the underlying grid
template.
</div>
<p>CSS is a simple, declarative language for creating style sheets that
specify the rendering of HTML and other structured documents. This
Note contains experimental ideas for <em>layout templates</em> and alternative
layout models in CSS.
<p>At the moment, it defines a <em>typographic grid</em> for
CSS. It has features to set up a grid-based template, to style the
<em>slots</em> of the template and to flow content into them.
<p>A grid template can be seen as a cross between table layout
(align blocks of text automatically in two-dimensions) and absolute
positioning (position elements in arbitrary order), but it also has
unique
features of its own.
<p>Grid templates can also be associated with pages in paged media
(via '@page'), to create <em>page templates.</em>
<p>Slots can form <em>chains,</em> to create non-rectangular
regions. A chain of slots is like a series of small pages: content is
broken at possible page breaks and distributed over the slots.
<p><em>Region-based styling</em> allows content to be styled not only
based on its position in the document tree, but also based on the slot
it finds itself in. This is achieved by allowing slot names to appear
in selectors.
<!--=================================================================-->
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--status-->
<p>This draft combines ideas from earlier drafts on Template Layout,
Grid Positioning [[CSS3GRID]] and Grid Layout [[CSS3-GRID-LAYOUT]].
<p>Issues on this draft are mentioned in the text itself and/or in the
on-line Tracker under <a
href="http://www.w3.org/Style/CSS/Tracker/products/15" >“Details on
Product CSS3 Template Layout.”</a>
<!-- Decided at Sep 2014 ftf: -->
<p><em>This document currently serves as a repository for ideas around
using templates for laying out elements, regions or pages; and for
various alternative layout models. It is expected to be updated, but
it is not expected to become a W3C Recommendation in this
form. Instead, ideas may migrate to other modules of CSS.</em>
<!--=================================================================-->
<nav id="toc">
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--toc-->
</nav>
<!--=================================================================-->
<h2>Introduction</h2>
<p><em>(This section is not normative.)</em>
<h3>Summary and use cases</h3>
<div class=sidefigure>
<p><img alt="Image: four elements move to four slots in a template"
longdesc=diagram.desc src=diagram.png>
<p class=caption>Above: a typical Web page. Below: the underlying grid
template. It has four slots, a, b, c and d and the grid template is
defined by 'grid: "a a a a a a a" "b c c c c d d"'.
</div>
<p class=mtb>The styling of a Web page, a form or a graphical user
interface can roughly be divided into 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
(different number of columns and rows, different order for the blocks
of content, less or more open space between those blocks, etc.),
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 associate a layout grid with
an element (or with a page, see below). Rather than rendering all
descendants of an element in a
single flow, they give an element multiple flows, called
<span>slots,</span> placed on an invisible grid by means of a
<span>grid template.</span> The descendants are given a 'flow'
property to designate the slot into which they flow.
<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 class=note>In some typographical traditions, the slots are called
“<span class=index title="field (of a typographical
grid)">fields</span>” or “<span class=index title="spatial
zone">spatial zones.</span>” Traditionally, also, all columns have the
same width, called the “<span class=index title="module (of a
typographical grid)">module</span>” or “<span class=index title="unit
(of a typographical grid)">unit</span>.” The horizontal lines of a
grid that define the rows are sometimes called “<span class=index
title="flow line">flow lines.</span>” Some traditions make the space
between pieces of content an explicit part of the grid, some consider
the space part of the content: Both styles are possible in CSS, the
latter by using the 'margin' property, the former by using the '.'
symbol in a grid template.
<p>The typical use cases for these properties include:
<ul>
<li><p>Complex Web pages, with multiple navigation bars in fixed
positions, areas for advertisements, etc.
<li><p>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, floats and margins.
<li><p>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.
<li><p>Paged displays (e.g., printed media) where each page
is divided into fixed areas for different kinds of content.
<li><p>Complex pages with multiple regions, where the style
of the text does not only depend on the type of element it comes from,
but also on the region it is displayed in (<em>region-based
styling</em>).
<li>Paged displays with complex running headers and footers, e.g.,
running headers that are in between parts of the page content, rather
than at the edge of the page.
</ul>
<p>Once a grid template has been defined, it can also be used to
position elements without adding them to a flow. Setting 'display:
grid' on a grid element makes all children into separate flows and
automatically distributes them over the grid. This is explained in
<cite>CSS Grid Layout</cite> [[!CSS3-GRID-LAYOUT]].
<p>Template-based positioning makes many traditional uses of
absolute positioning unnecessary. Like absolute positioning, grid
templates are 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 flowing them into a template that is very much
like a table: The size and alignment of elements are governed
implicitly by the rows and columns of the template, and can
automatically adapt to the overall size of the element and to the
content in each row and column.
<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 alt="Image: sample rendering" longdesc=aapje.desc
src=aapje.png>
<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: "a b"
"c d" }
#sym1 { flow: a }
#lab1 { flow: b }
#sym2 { flow: c }
#lab2 { flow: 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>
<p><a href="ex-aapje.html">Try it out!</a> (Uses a JavaScript
emulation in browsers that do not implement grid templates natively.)
</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: "a a a"
"b c d" }
#head { flow: a }
#nav { flow: b }
#adv { flow: c }
#body { flow: d }
}
@media all and (max-width: 500px)
{
body { grid: "a"
"b"
"c" }
#head { flow: a }
#nav { flow: b }
#adv { display: none }
#body { flow: c }
}
</pre>
</div>
<div class=example>
<p>The slots in a grid do not 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 CSS Zen Garden could be done:
<pre>
#container {grid: "A B C"}
#container::slot(A) {box-shadow: 0.5em 0.5em 0.5em; z-index: 1}
#container::slot(B) {box-shadow: 0.5em 0.5em 0.5em; margin-left: -2em}
#intro {flow: A}
#supportingText {flow: B}
#linkList {flow: 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 one another'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 alt="[Three unequal cells]" longdesc=table1.desc
src=table1.png>
<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: "a b c"}
.group > div {flow: a}
.group > div + div {flow: b}
.group > div + div + div {flow: 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; <i>width: 100%</i>}</pre>
<p>That is not needed for the grid template, but, on the other hand,
if we want the template to fit its contents, we would need to say so:
<pre>.group {grid: "a b c"; <i>width: fit-content</i>}</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 their sizes may
differ. We can make them all the same by adding a rule (see
[[!CSS3TBL]]):
<pre>.group {display: table; width: 100%; <i>table-layout: fixed</i>}</pre>
<div class=figure>
<p><img alt="[Three equal cells]" longdesc=table2.desc src=table2.png>
<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:nth-child(3) {<i>width: 3em</i>}</pre>
<p>resp.,
<pre>.group {grid: <i>* * 3em</i> "a b c"}</pre>
<div class=figure>
<p><img alt="[Two equal cells, third is 3em wide]"
longdesc=table3.desc src=table3.png>
<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>(However, setting 'display' to 'grid' on the grid element creates a
different kind of grid, that <em>does</em> grow, see <a
href="#absolute">“Comparison with 'display: grid' and 'display:
inline-grid'”</a> below.)
<p>In both models, elements can have borders, but only in the table
model can borders be collapsed, which makes setting borders easier in
the table model:
<pre>
.group {display: table; <i>border-collapse: collapse</i>}
.group > div {<i>border: solid</i>}
</pre>
<p>resp.,
<pre>
.group > div {<i>border: solid; border-left: none</i>}
.group > div:first-child {<i>border-left: solid</i>}
</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 {flow: <i>c</i>}
.group > div + div {flow: b}
.group > div + div + div {flow: <i>a</i>}
</pre>
<div class=figure>
<p><img alt="[Different contents for the cells]" longdesc=table4.desc
src=table4.png>
<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 cannot be changed.
</div>
<div class=example>
<p>[Editorial note: Remove this example if the 'content' property will
<em>not</em> be allowed on elements, as it is currently expected to
be.]
<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: "*"
"F"}
.note {
flow: F;
content: counter(note) ".\A0" contents;
counter-increment: note;
font-size: smaller}
.note::before {
content: counter(note);
vertical-align: super;
font-size: larger}
</pre>
<p>results in a rendering similar to this:
<div class=figure>
<p><img alt="Same text, with the SPAN replaced by “(1)” and its
content moved to the end." longdesc=footnotes.desc src=footnotes.png>
<p class=caption>Rendering of a text with footnotes.
</div>
<p>The “Generated content for paged media” module [[CSS3GCPM]] is
expected to define specific features for footnotes that are both
easier and more powerful than this example.
</div>
<div class=example>
<p>This example shows the use of <span class=index title=chain>chained
regions:</span> text from region 1
continues in region 2, 3 and 4. And it shows how to use
pseudo-elements to style text in a particular region: text in region 1
is bigger than in other regions.
<div class=figure>
<p><img alt="Image of a complex, 3-column layout"
longdesc=regions-intro-rendering.desc src=regions-intro-rendering.png>
<p class=caption>Example rendering
</div>
<p>We assume a document fragment similar to this:
<pre>
<div id=article>
<h1>Introduction</h1>
<p><img src="sunset" alt="">
<p>This is an example…
<h1>More Details</h1>
<p>This illustrates…
<p>Then, the example…
<p>Finally, this…
</div>
</pre>
<p>The style sheet makes the DIV into a grid element with five
regions, called A, *, b, c and d. The regions are grouped into two
chains: region A on its own, and the chain consisting of *, b, c and
d.
<pre>
#article {
<span class=index>grid</span>: "A A c"
"A A c"
"* * c"
"a b c";
<span class=index>chains</span>: * a b c }
</pre>
<p>The '*' is a special name. It indicates the <em>default slot,</em>
the slot where content goes if it doesn't have an explicit 'flow'
property. We could have used a normal letter and added an explicit
'flow' property to the children of the DIV, but by using * we don't
have to. All children thus go into region * (and continue in a, b and
c as needed). The IMG element goes into region A. We assume for
simplicity that there is only one IMG element:
<pre>#article img { flow: A }</pre>
<p>The text in region * is bolder, larger and a different color than
in the other regions. Also, an H1 that falls into this region is
rendered differently from other H1s:
<pre>
<span class=index>@region</span> ::slot(*)
{
* {
font-weight: bold;
color: #0C3D5F;
font-size: larger }
h1 {
color: crimson;
display: run-in }
}
</pre>
<p>(For brevity, the example doesn't show the style rules to set the
color and background, to make the text justified, add the left border
to the second H1, etc.)
<p>As the image shows, the text of the last paragraph isn't complete
and presumably continues somewhere else, but that part is outside the
scope of this example. In paged media, we could attach the grid
template to a page instead of an element and let the text continue on
the next page; we could also make slot c into a multi-column element
so that the text forms additional columns to the right of current
image (see [[CSS3GCPM]] for some ideas), or there could be a scrollbar
on slot c.
</div>
<div class=example>
<p>This example shows three ways to align the contents of a
fixed-height paragraph to the bottom of the box:
<dl>
<dt>Method 1 <dd>
<pre>P {height: 20em; grid: "." "*" fit-content}</pre>
<dt>Method 2 <dd>
<pre>P {height: 20em; grid: "*"}
P::slot(*) {vertical-align: bottom}</pre>
<dt>Method 3 <dd>
[Editorial note: Remove method 3 if <span
class=index>vertical-align</span> will <em>not</em> be generalized to
apply to all blocks.]
<pre>P {height: 20em; vertical-align: bottom}</pre>
</dl>
<p>However, the styles differ in case the content is taller than 20 em
and overflows: the first style has a baseline-aligned content which
will thus overflow <em>below</em> the element's box; the second
example has bottom-aligned content, which will thus overflow
<em>above</em> the element's box.
</div>
<div class=example>
<p>This example (based on a challenge by Andrew Fedoniouk) shows how a
grid template can be used to display six items in two rows of
three. Assume the following document:
<pre>
<p>
<span>...</span>
<span>...</span>
<span>...</span>
<span>...</span>
<span>...</span>
<span>...</span>
</p>
</pre>
<p>The simplest way to break this into two lines (or more) is to add a
hard line break after the third SPAN: ''span:nth-child(3)::after
{content: "\A"; white-space: pre}''. That works fine, unless the SPANs
are inline blocks (''span {display: inline-block}''). Another way is
to float all SPANs and add a 'clear' property on the fourth: ''span
{float: left} span:nth-child(4) {clear: left}''. But if the SPANs have
different heights or baselines, their vertical alignment will be
different than if they were on the same line.
<p>With a grid template, we can say that the P has not one, but two
flows, a and b, the second one positioned below the first; and then we
assign the fourth and subsequent SPANs to
the “b” flow. (The others automatically go into the default, first
flow.)
<pre>
p {grid: "a" "b"}
span:nth-child(n+4) {flow: b}
</pre>
<p>This almost works. There is just a subtle issue with the spaces
between the SPANs. We moved the last three SPANs to flow b, but we
have no way to move the spaces between them. They remain in the
default (first) slot. (They collapse, as there is nothing left between
them, so we don't actually see them anymore.) To get spaces between
the SPANs in slot b, we need to generate new spaces:
<pre>span:nth-child(n+4)::after {content: " "}</pre>
<p class=issue>This space handling is not very intuitive. One might
expect there to be a way to say “select everything from this element
onward” or maybe a pseudo-element selector for the text between
elements. Or a new property to specify different ways to handle the
anonymous text inside a grid element. For the moment, there is no such
thing. Suggestions are welcome.
<p>If, on the other hand, we <em>don't</em> want spaces between the
SPANs, then the question becomes how to get rid of the spaces between
the SPANs in the first row. There are several ways of doing that. One
way is to explicitly flow the three first SPANs to slot “a”:
<pre>span {flow: a}</pre>
<p>The SPANs are thus taken out of the P, causing the P's spaces to
end up next to each other at the start of flow “a” and collapse
away. Another, maybe more intuitive way is to set the spaces to zero
width in the P, and then back to normal in the SPANs (see
'word-spacing' in [[CSS3TEXT]]):
<pre>
p {word-spacing: -100%}
span {word-spacing: normal}
</pre>
<p>[Editorial note: Remove this last method if percentage values on
'word-spacing' will not be allowed. They currently (March 2015) have
Working Draft status.]
</div>
<div class=example>
<p>This example uses a <em>page-based template</em> to create a
running header that is not at the top of the page, but exactly in the
middle. We need to define our own page template for this, because the
predefined page template of [[CSS3PAGE]] only has margin boxes along
the edge of the page.
<pre>
@page {
grid:
"top-half"
"running-header" 3em
"bottom-half";
chains: top-half bottom-half
}
::slot(running-header) {
content: "My Magazine - page " counter(page) " - February 2013";
text-align: center;
<span class=index>vertical-align</span>: middle;
border: solid;
margin: 1em 0;
}
</pre>
<div class=figure>
<p><img src="page.png" alt="Image: Example rendering" longdesc="page.desc">
<p class=caption>An example of a page rendered with the above page
template. It has the “running header” with the page number right in
the middle of the page.
</div>
</div>
<!--=================================================================-->
<h3 id=dependencies>Dependencies on other modules</h3>
<p>This CSS3 module depends on the following other CSS3 modules:
<ul>
<li><cite>CSS 2.1</cite> [[!CSS21]]
– <a href="https://www.w3.org/TR/CSS21/visuren.html#block-boxes"
><dfn>block container,</dfn></a> the property <dfn>content,</dfn> and
the concept of <dfn>stacking context.</dfn>
<li><cite>CSS syntax module</cite> [[!CSS3SYN]] –
<dfn>interactive</dfn> vs <dfn>non-interactive</dfn> media.
<li><cite>CSS values and Units module</cite> [[!CSS3VAL]] – <a
href="https://www.w3.org/TR/css3-values#strings">
<dfn><var><string></var></dfn></a> and <a
href="https://www.w3.org/TR/css3-values#length-value">
<dfn><var><length></var></dfn></a>.
<li><cite>CSS box module</cite> [[!CSS3BOX]] – properties
<dfn>margin</dfn>, <dfn>margin-right</dfn>, <dfn>margin-left</dfn>,
<dfn>width</dfn>, <dfn>height</dfn>, <dfn>float</dfn>,
<dfn>display</dfn> and <dfn>overflow</dfn>; definitions of the terms
<dfn>intrinsic minimum</dfn> and <dfn>intrinsic preferred</dfn> (as in
the phrases “intrinsic preferred width” and “intrinsic minimum width,”
referring roughly to the width of the content without breaking any
lines and the width with as many line breaks as possible.)
<li><cite>CSS text layout</cite> [[!CSS3-WRITING-MODES]] –
defines <dfn>block flow direction</dfn> and the
properties <dfn>direction</dfn> and <dfn>writing-mode</dfn>. The
latter defines when an element has 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>
<li><cite>CSS positioning</cite> [[!CSS3POS]] – properties
<dfn>z-index</dfn>, <dfn>position</dfn>, <dfn>top</dfn>,
<dfn>right</dfn>, <dfn>bottom</dfn>, <dfn>left</dfn>.
<li><cite>CSS fragmentation</cite> [[CSS3-BREAK]] – properties
<dfn>break-before</dfn>, <dfn>break-after</dfn> and
<dfn>break-inside</dfn>; the definition of <dfn>fragmenter</dfn>.
<li><cite>CSS paged media</cite> [[CSS3PAGE]] – definition of
<dfn>page area</dfn> (in particular its width & height).
<li><cite>CSS background and borders</cite> [[CSS3BG]] –
properties <dfn>background</dfn>, <dfn>background-image</dfn>,
<dfn>background-size</dfn>, <dfn>box-decoration-break</dfn>
<span class=issue>and <dfn>box-shadow</dfn>?</span>
<li><cite>CSS tables</cite> [[!CSS3TBL]] – property
<dfn>vertical-align</dfn>. <span class=issue>[or Box Module?]</span>
<li><cite>CSS Multi-column Layout Module</cite> [[CSS3COL]] –
property <dfn>columns</dfn>.
<li><cite>CSS Generated and replaced content module level 3</cite>
[[!CSS3GENCON]] – property <dfn>content</dfn>.
<li><cite>CSS regions</cite> [[!CSS3-REGIONS]] – at-rule
<dfn>@region</dfn> and the term <dfn>region.</dfn>
<li><cite>CSS Grid Layout</cite> [[!CSS3-GRID-LAYOUT]] – the
term <dfn>grid container</dfn> and the properties
<dfn>grid-auto-flow</dfn>, <dfn>grid-auto-columns</dfn> and
<dfn>grid-auto-rows</dfn>. (Note: A grid container is an element with
a 'display' of ''grid'' or ''grid-inline''.)
<li><cite>CSS Cascading and Inheritance Level 3</cite>
[[!CSS3CASCADE]] – keywords <dfn>inherit,</dfn>
<dfn>initial</dfn> and <dfn>unset.</dfn>
</ul>
<p class=issue>Add to the above all the properties that are allowed on
slots (see <a href="#slot-pseudo">“Styling slots: the ''::slot()''
pseudo-element”</a>).
<p>It has non-normative (informative) references to the following other
CSS3 modules:
<ul>
<li><cite>Selectors</cite> [[SELECT]]
<li><cite>CSS Text Module Level 3</cite> [[CSS3TEXT]] – the
<dfn>word-spacing</dfn> property
</ul>
<p>See <a
href="https://www.w3.org/TR/CSS21/about.html#property-defs" >section 1.4.2
of CSS level 2</a> [[CSS21]] for the grammar and other notations
that this specification uses in property definitions.
<!--=================================================================-->
<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 ''inherit'', ''initial'', and ''unset'' keywords as their
property value.
<!--=================================================================-->
<h3 id=accessibility>A note about accessibility</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>
<!--=================================================================-->
<h2>Stack of cards layout</h2>
<p class=issue>This is a placeholder.
<p>A stack is a layout model based on the metaphor of a stack of index
cards: sibling elements are formatted as boxes (<dfn
title="card">“cards”</dfn>) of the same size at the same position with
a <dfn>tab</dfn> sticking out at one side that contains a title for
that card. All tabs are visible (and automatically positioned so they
overlap as little as possible), but only one box is visible at a
time. In an interactive UA, the user can activate a card (e.g., by
clicking on a tab, or by pressing page-down), which displays that card
and hides all the others in the stack. E.g., a rule 'display: stack'
could make an element into a stack of cards (all children become
cards, sized to the largest among them) and 'display: tab' could make
their descendants into titles for the cards. Maybe other properties
determine the style of the tabs and on which side they display (top,
bottom, left or right).
<!--=================================================================-->
<h2>Declaring templates</h2>
<p>Grid templates are declared with the 'grid-template-areas', 'grid-template-rows',
'grid-template-columns' and 'grid' properties, defined below.
<p>An element that has a grid template is called a <dfn>grid
element.</dfn> More precisely: an element is a grid element if (1) it
generates a <span>block container</span> box [[!CSS21]] and (2) at
least one of 'grid-template-areas', 'grid-template-rows' or 'grid-template-columns' has a
value other than the initial value.
<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>An element's <dfn>grid ancestor</dfn> is the nearest ancestor that
is a <span>grid element.</span>
<p class=note>Note that not all elements have a grid ancestor. E.g.,
the root element has none.
<p>The <dfn>number of columns</dfn> of a grid element is the number
of <var><col-width></var> values in 'grid-template-columns' or the number
of columns in 'grid-template-areas', whichever is larger.
<p>The <dfn>number of rows</dfn> is the number
of <var><row-height></var> values in 'grid-template-rows' or the number
of rows in 'grid-template-areas', whichever is larger.
<p class=note>Note that a grid element always has at least one row and one
column. Those may, however, have zero size.
<!--=================================================================-->
<h3 id=grid-template >Declaring a template: 'grid-template-areas'</h3>
<p>The 'grid-template-areas' property implicitly assigns a grid to an
element and defines named slots in the grid. It can also designate a
slot as the <em>default slot</em> for content without an explicit
flow.
<table class=propdef>
<tbody>
<tr><th>Name: <td><dfn>grid-template-areas</dfn>
<tr><th><a href="#values" >Value</a>: <td>none | <var><string></var>+
<tr><th>Initial: <td>none
<tr><th>Applies to: <td><span>block container</span> elements [[!CSS21]] and <em>grid container</em> elements [[!CSS3-GRID-LAYOUT]]
<tr><th>Inherited: <td>no
<tr><th>Animatable: <td>no
<tr><th>Percentages: <td>N/A
<tr><th>Computed value: <td>specified value
<tr><th>Canonical order: <td><abbr title="follows order of property
value definition">per grammar</abbr>
</table>
<p>Each string consist of one or more asterisks (“*”), identifiers,
periods (“.”), spaces and tabs. Each string represents one row in the
template, each symbol other than a space or tab represents one column
in that row. Spaces and tabs have no meaning. They separate
identifiers and may also be added for readability.
<p>The symbols in the template have the following meaning
<dl>
<dt><identifier>
<dd>
Named slot for content.
<!--
<p class=issue>Unicode normalization is not yet
defined in css3-values nor anywhere else. E.g., we want é to match é,
no matter if the author typed U+0301 U+0065 or U+00C9.)
-->
<dt>*
<dd>
(Asterisk.) Default slot for content (explained below).
<dt>.
<dd>
(Period.) Blank space.
</dl>
<p>Multiple identical identifiers in adjacent rows or columns form a
single <dfn>slot</dfn> that spans those rows and columns. Ditto for
multiple “*”s. Slot names are case-sensitive, so uppercase and
lowercase letters are considered to be different letters.
<p class=issue>Case-sensitivity should instead be defined by reference
to the definition of identifiers, probably in css3-values.
<p>Non-rectangular slots and multiple slots with the same name are
illegal. A template without any slot name or “*” is illegal. A template
with more than one “*” slot is illegal. Strings with different numbers
of columns (<em>before</em> padding with “.”, see the next paragraph) are
illegal. These errors cause the declaration to be ignored.