-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
executable file
·4051 lines (3206 loc) · 157 KB
/
Overview.html
File metadata and controls
executable file
·4051 lines (3206 loc) · 157 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
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">
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED.css" rel=stylesheet
type="text/css">
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS Template Layout Module</h1>
<h2 class="no-num no-toc" id=longstatus-date-3-august-2004>Editor's Draft
23 February 2012</h2>
<dl>
<dt>This version:
<dd><a href="http://www.w3.org/TR/2012/ED-css3-layout-20120223/">
http://www.w3.org/TR/2012/ED-css3-layout-20120223/</a>
<dt>Latest version:
<dd><a href="http://www.w3.org/TR/css3-layout/">
http://www.w3.org/TR/css3-layout/</a>
<dt>Previous version:
<dd><a href="http://www.w3.org/TR/2011/WD-css3-layout-20111129/">
http://www.w3.org/TR/2011/WD-css3-layout-20111129/</a>
<dt>Editors:
<dd class=vcard><span class=fn>Bert Bos</span> (<span
class=org>W3C</span>) <a class=email
href="mailto:bert@w3.org">bert@w3.org</a>
<dd class=vcard><span class=fn>César Acebal</span> (<span
class=org>University of Oviedo</span>)
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2012 <a
href="http://www.w3.org/"><acronym
title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><acronym
title="Massachusetts Institute of Technology">MIT</acronym></a>, <a
href="http://www.ercim.eu/"><acronym
title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>,
<a href="http://www.keio.ac.jp/">Keio</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>
<!--end-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>A grid with four slots defined by ‘<code
class=css>display: "aaaaaaa" "bccccdd"</code>’.
</div>
<p>CSS is a simple, declarative language for creating style sheets that
specify the rendering of HTML and other structured documents. This module
contains CSS features to describe layouts at a high level, meant for tasks
such as the positioning and alignment of “widgets” in a graphical user
interface or the layout grid for a page or a window.
<p>A layout grid or “template” defines one or more “slots” that an
element's content can flow into. This allows elements to have complex
shapes and it allows the visual order to be different from the order of
the elements in the source document.
<p>A ‘<a href="#slot"><code class=css>::slot</code></a>’
selector allows elements to be styled differently based on which slot they
appear in.
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<!--begin-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=%5Bcss3-layout%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
“css3-layout” in the subject, preferably like this:
“[<!---->css3-layout<!---->] <em>…summary of
comment…</em>”
<p>This document was produced by the <a href="/Style/CSS/members">CSS
Working Group</a> (part of the <a href="/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent
Policy</a>. W3C maintains a <a href="/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="/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the
W3C Patent Policy</a>.</p>
<!--end-status-->
<p>This draft is related to the drafts about positoning with grid units
(‘<code class=property>gr</code>’), creating and naming grids
and regions <a href="#CSS3-GRID-LAYOUT"
rel=biblioentry>[CSS3-GRID-LAYOUT]<!--{{CSS3-GRID-LAYOUT}}--></a>,
flexible <abbr title="Graphical User Interfaces">GUIs</abbr> <a
href="#CSS3-FLEXBOX"
rel=biblioentry>[CSS3-FLEXBOX]<!--{{CSS3-FLEXBOX}}--></a>, and tables <a
href="#CSS3TBL" rel=biblioentry>[CSS3TBL]<!--{{!CSS3TBL}}--></a>. The CSS
Working Group is considering combining some or all of these into a single
specification with all matrix-based layouts.
<p>The section on <a href="#cr-exit-criteria">“CR exit criteria”</a>
lists some conditions for this specification to become a W3C
Recommendation.
<p>Issues on this draft are mentioned in the text itself (<span
class=issue>like this</span>) 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>
<h2 class="no-num no-toc" id=contents>Table of contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#dependencies"><span class=secno>1. </span>Dependencies on
other modules</a>
<li><a href="#introduction"><span class=secno>2. </span>Introduction</a>
<li><a href="#accessibility"><span class=secno>3. </span>A note about
accessibility</a>
<li><a href="#features-out-of-scope"><span class=secno>4. </span>Features
out of scope</a>
<ul class=toc>
<li><a href="#repeating-templates"><span class=secno>4.1.
</span>Repeating templates</a>
<li><a href="#non-rectangular-shapes-and-wrap-arounds"><span
class=secno>4.2. </span>Non-rectangular shapes and wrap-arounds</a>
</ul>
<li><a href="#declaring-templates-the-display-property"><span
class=secno>5. </span>Declaring templates: the ‘<code
class=property>display</code>’ property</a>
<li><a href="#slot-sizes"><span class=secno>6. </span> Calculating the
size of the grid</a>
<li><a href="#position"><span class=secno>7. </span>Flowing content into
the template: the ‘<code class=property>position</code>’
property</a>
<li><a href="#slot-pseudo"><span class=secno>8. </span>The ‘<code
class=css>::slot()</code>’ pseudo-element</a>
<li><a href="#vertical-alignment"><span class=secno>9. </span>Vertical
alignment</a>
<li><a href="#paged"><span class=secno>10. </span>Page-based templates and
other templates in paged media</a>
<li><a href="#stacking-order"><span class=secno>11. </span>Stacking
order</a>
<li><a href="#floating-elements-inside-templates"><span class=secno>12.
</span>Floating elements inside templates</a>
<li><a href="#gr-unit"><span class=secno>13. </span>Definition of the
‘<code class=css>gr</code>’ unit in a template element</a>
<li><a href="#chains"><span class=secno>14. </span>Chaining slots: the
‘<code class=property>chains</code>’ property</a>
<li><a href="#breaking-content-between-slots-in-a-chai"><span
class=secno>15. </span>Breaking content between slots in a chain</a>
<li><a href="#cr-exit-criteria"><span class=secno>16. </span>CR exit
criteria</a>
<li><a href="#history"><span class=secno>17. </span>History</a>
<ul class=toc>
<li><a href="#developing-a-model-of-declaring-using-st"><span
class=secno>17.1. </span>Developing a model of declaring, using,
styling and resizing grids</a>
<li><a href="#syntax-features-and-levels"><span class=secno>17.2.
</span>Syntax, features and levels</a>
<ul class=toc>
<li><a href="#named-vs-numbered-slots"><span class=secno>17.2.1.
</span>Named vs numbered slots</a>
<li><a href="#single-letter-names-vs-identifiers"><span
class=secno>17.2.2. </span>Single letter names vs identifiers</a>
<li><a href="#extend-display-or-add-a-grid-property"><span
class=secno>17.2.3. </span>Extend ‘<code
class=property>display</code>’ or add a grid property</a>
<li><a href="#combining-columns-and-grids"><span class=secno>17.2.4.
</span>Combining columns and grids</a>
<li><a href="#shorthand-vs-single-property"><span class=secno>17.2.5.
</span>Shorthand vs single property</a>
<li><a href="#the-number-of-rows-and-columns"><span
class=secno>17.2.6. </span>The number of rows and columns</a>
<li><a href="#need-fr"><span class=secno>17.2.7. </span>‘<code
class=css>*</code>’ vs ‘<code
class=property>fr</code>’</a>
<li><a href="#auto-add"><span class=secno>17.2.8. </span>Automatically
add rows and columns</a>
<li><a href="#rectangular-slots-vs-non-rectangular-slo"><span
class=secno>17.2.9. </span>Rectangular slots vs non-rectangular
slots</a>
<li><a href="#chained"><span class=secno>17.2.10. </span>Chained
slots</a>
<li><a href="#page-grid"><span class=secno>17.2.11. </span>Page
grids</a>
<li><a href="#style-the-slots-pseudo-elements"><span
class=secno>17.2.12. </span>Style the slots (pseudo-elements)</a>
<li><a href="#style-the-contents-of-slots-region-based"><span
class=secno>17.2.13. </span>Style the contents of slots (region-based
styling)</a>
<li><a href="#orient-the-grid-with-writing-mode-vs-ori"><span
class=secno>17.2.14. </span>Orient the grid with writing mode vs
orient the slots</a>
<li><a href="#indicating-the-default-slot-vs-"><span
class=secno>17.2.15. </span>Indicating the default slot (‘<code
class=css>*</code>’ vs ‘<code
class=css>@</code>’)</a>
<li><a href="#abspos"><span class=secno>17.2.16. </span>Flowing vs
absolutely positioning content in a grid</a>
<li><a href="#use-the-pseudo-class-to-create-additiona"><span
class=secno>17.2.17. </span>Use the pseudo-class to create additional
slots</a>
<li><a href="#names-for-edges"><span class=secno>17.2.18. </span>Names
for edges</a>
<li><a href="#position-from-the-right-and-bottom"><span
class=secno>17.2.19. </span>Position from the right and bottom</a>
<li><a href="#syntax-features-to-shorten-long-grid-spe"><span
class=secno>17.2.20. </span>Syntax features to shorten long grid
specifications</a>
<li><a href="#fit-content-vs-auto-vshellip"><span class=secno>17.2.21.
</span>‘<code class=css>fit-content</code>’ vs
‘<code class=css>auto</code>’ vs…</a>
<li><a href="#vert-align"><span class=secno>17.2.22. </span>Vertical
alignment inside slots</a>
<li><a href="#horizontal-alignment-inside-slots"><span
class=secno>17.2.23. </span>Horizontal alignment inside slots</a>
<li><a href="#auto-margins-on-slots"><span class=secno>17.2.24.
</span>Auto margins on slots</a>
<li><a href="#page-floats"><span class=secno>17.2.25. </span>Page
floats</a>
<li><a href="#break-properties"><span class=secno>17.2.26.
</span>Break-* properties</a>
<li><a href="#next-same"><span class=secno>17.2.27. </span>Automatic
placement of elements</a>
</ul>
</ul>
<li><a href="#changes"><span class=secno>18. </span>Changes</a>
<li class=no-num><a href="#acknowledgments">Acknowledgments</a>
<li class=no-num><a href="#references">References</a>
<li class=no-num><a href="#index">Index</a>
</ul>
<!--end-toc-->
<h2 id=dependencies><span class=secno>1. </span>Dependencies on other
modules</h2>
<p>This CSS3 module depends on the following other CSS3 modules:
<ul>
<li><cite>CSS syntax module</cite> <a href="#CSS3SYN"
rel=biblioentry>[CSS3SYN]<!--{{!CSS3SYN}}--></a> – <dfn
id=interactive>interactive</dfn> vs <dfn
id=non-interactive>non-interactive</dfn> media.
<li><cite>CSS values and Units module</cite> <a href="#CSS3VAL"
rel=biblioentry>[CSS3VAL]<!--{{!CSS3VAL}}--></a> – <a
href="/TR/css3-values#strings"> <dfn
id=ltstringgt><var><string></var></dfn></a> and <a
href="/TR/css3-values#length-value"> <dfn
id=ltlengthgt><var><length></var></dfn></a>.
<li><cite>CSS box module</cite> <a href="#CSS3BOX"
rel=biblioentry>[CSS3BOX]<!--{{!CSS3BOX}}--></a> – properties <dfn
id=width>width</dfn>, <dfn id=height>height</dfn>, <dfn
id=float>float</dfn>, <dfn id=display>display</dfn> and <dfn
id=overflow>overflow</dfn>
<li><cite>CSS text layout</cite> <a href="#CSS3TEXTLAYOUT"
rel=biblioentry>[CSS3TEXTLAYOUT]<!--{{!CSS3TEXTLAYOUT}}--></a> –
properties <dfn id=direction>direction</dfn> and <dfn
id=block-flow>block-flow</dfn>
<li><cite>CSS positioning</cite> <a href="#CSS3POS"
rel=biblioentry>[CSS3POS]<!--{{!CSS3POS}}--></a> – property <dfn
id=z-index>z-index</dfn>
<li><cite>CSS paged media</cite> <a href="#CSS3PAGE"
rel=biblioentry>[CSS3PAGE]<!--{{!CSS3PAGE}}--></a> – properties
<dfn id=page-break-before>page-break-before</dfn>, <dfn
id=page-break-after>page-break-after</dfn> and <dfn id=page>page</dfn>;
<a href="/TR/css3-page#page-area0"><dfn id=page-area>page area</dfn></a>
(in particular its width & height).
<li><cite>CSS background and borders</cite> <a href="#CSS3BG"
rel=biblioentry>[CSS3BG]<!--{{!CSS3BG}}--></a> – property <dfn
id=background>background</dfn> <span class=issue>and <dfn
id=box-shadow>box-shadow</dfn>?</span>
<li><cite>CSS tables</cite> <a href="#CSS3TBL"
rel=biblioentry>[CSS3TBL]<!--{{!CSS3TBL}}--></a> – property <dfn
id=vertical-align>vertical-align</dfn>. <span class=issue>[or Box
Module?]</span>
<li><cite>CSS Multi-column Layout Module</cite> <a href="#CSS3COL"
rel=biblioentry>[CSS3COL]<!--{{!CSS3COL}}--></a> – properties <dfn
id=break-before>break-before</dfn>, <dfn id=break-after>break-after</dfn>
and <dfn id=break-inside>break-inside</dfn>.
</ul>
<p class=issue>Add to the above all the properties that are allowed on
slots (see <a href="#slot-pseudo">“The ‘<code
class=css>::slot()</code>’ pseudo-element”</a>).
<p>It has non-normative (informative) references to the following other
CSS3 modules:
<ul>
<li><cite>Selectors</cite> <a href="#SELECT"
rel=biblioentry>[SELECT]<!--{{SELECT}}--></a>
</ul>
<p>See <a
href="http://www.w3.org/TR/CSS21/about.html#property-defs">section 1.4.2
of CSS level 2</a> <a href="#CSS21"
rel=biblioentry>[CSS21]<!--{{CSS21}}--></a> for the grammar and other
notations that this specification uses in property definitions.
<h2 id=introduction><span class=secno>2. </span>Introduction</h2>
<p><em>(This section is not normative.)</em>
<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>Four regions, 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 <em>layout
policy</em> 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, called <em>template-based positioning,</em> gives an element an
invisible grid for aligning 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.
<li>Paged displays (e.g., printed media) where each page is divided in
fixed areas for different kinds of content.
<li>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.
</ul>
<p>Template-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. A template doesn't
allow elements to overlap, but it provides layouts that adapt better to
different widths.
<p class=issue>Call it a “slot” or rather a “region”?
<p>The mapping is done with the ‘<a href="#position0"><code
class=property>position</code></a>’ property, which specifies in
this case into which slot of the template the element goes. The template
itself is specified on the ‘<a href="#display"><code
class=property>display</code></a>’ 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 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 { display: "ab"
"cd" }
#sym1 { position: a }
#lab1 { position: b }
#sym2 { position: c }
#lab2 { position: 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 <a href="#MEDIAQ"
rel=biblioentry>[MEDIAQ]<!--{{MEDIAQ}}--></a> 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 { display: "aaa"
"bcd" }
#head { position: a }
#nav { position: b }
#adv { position: c }
#body { position: d }
}
@media all and (max-width: 500px)
{
body { display: "a"
"b"
"c" }
#head { position: a }
#nav { position: b }
#adv { display: none }
#body { position: 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 { display: "abc" }
#intro { position: a; margin-right: -2em; box-shadow: 0.5em 0.5em 0.5em }
#supportingText { position: b; box-shadow: 0.5em 0.5em 0.5em }
#linkList { position: 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 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 {display: "abc"}
.group > div {position: a}
.group > div + div {position: b}
.group > div + div + div {position: 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 {display: "abc"; width: fit-content}</pre>
<p>(See <a href="#CSS3BOX"
rel=biblioentry>[CSS3BOX]<!--{{!CSS3BOX}}--></a> for the definition of
the ‘<a href="#width"><code class=property>width</code></a>’
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 <a
href="#CSS3TBL" rel=biblioentry>[CSS3TBL]<!--{{!CSS3TBL}}--></a>):
<pre>.group {display: table; width: 100%; table-layout: fixed}</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.menu {width: 3em}</pre>
<p>resp.,
<pre>.group {display: "abc" * * 3em}</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 ‘<code class=css>a</code>’
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: c}
.group > div + div {position: b}
.group > div + div + div {position: a}
</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 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 {
display: "@" available
"F" available}
.note {
position: F;
content: counter(note) ".\A0" contents;
counter-increment: note;
font-size: smaller}
.note::before {
content: counter(note);
position: @;
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>
</div>
<div class=example>
<p>This example shows the use of chained regions: 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>
<p><img src="sunset" alt="">
<h1>Introduction</h1>
<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 template element with five
regions, called A, 1, 2, 3 and 4. The regions are grouped into two
chains: region A on its own, and the chain consisting of 1, 2, 3 and 4.
<pre>
#article {
display: "A A 4"
"A A 4"
"1 1 4"
"2 3 4";
chains: 1 2 3 4 }
</pre>
<p>All children go into region 1 (and continue in 2, 3 and 4 as needed).
The IMG element goes into region A. We assume for simplicity that there
is only one IMG element:
<pre>
#article > * { position: 1 }
#article img { position: A }
</pre>
<p>The text in region 1 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>
::slot(1) {
font-weight: bold;
color: #0C3D5F;
font-size: larger }
h1::slot(1) {
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.)
</div>
<h2 id=accessibility><span class=secno>3. </span>A note about accessibility</h2>
<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 <a href="#CSS3UI"
rel=biblioentry>[CSS3UI]<!--{{CSS3UI}}--></a> 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 <a href="#WCAG20"
rel=biblioentry>[WCAG20]<!--{{WCAG20}}--></a> are particularly relevant.
See that specification for more information.
<blockquote>
<p><a
href="http://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="http://www.w3.org/TR/2008/REC-WCAG20-20081211/#correct-reading-sequencedef">correct
reading sequence</a> can be <a
href="http://www.w3.org/TR/2008/REC-WCAG20-20081211/#programmaticallydetermineddef ">programmatically
determined.</a> (Level A)
</blockquote>
<blockquote>
<p><a
href="http://www.w3.org/TR/2008/REC-WCAG20-20081211/#navigation-mechanisms-focus-order"><strong>2.4.3
Focus Order:</strong></a> If a <a
href="http://www.w3.org/TR/2008/REC-WCAG20-20081211/#webpagedef">Web
page</a> can be <a
href="http://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 id=features-out-of-scope><span class=secno>4. </span>Features out of
scope</h2>
<p>A number of features that are related to grid layouts are not handled in
this module. Some of them are in other modules.
<h3 id=repeating-templates><span class=secno>4.1. </span>Repeating
templates</h3>
<p>The templates defined by this specification have a fixed number of
slots, independent of the amount of content or the number of child
elements. In some situations it may be useful to define a template and
then, in the case there is more content than fits, automatically create
new copies of the template, to the side of or below the first one, just
like new pages are created in paged media or new columns in multi-column
layouts.
<p>In some cases it may be possible to simulate that behavior by putting
the template element inside a column layout.
<h3 id=non-rectangular-shapes-and-wrap-arounds><span class=secno>4.2.
</span>Non-rectangular shapes and wrap-arounds</h3>
<p>This specification allows to chain multiple slots together to form
complex shapes, but each of the slots is itself still rectangular.
<p>Another module, <cite>CSS exclusions and shapes</cite> <a
href="#CSS3-EXCLUSIONS"
rel=biblioentry>[CSS3-EXCLUSIONS]<!--{{CSS3-EXCLUSIONS}}--></a>, is
expected to allow floating elements to have non-rectangular shapes and
allow positioned elements to cause wrap-around.
<h2 id=declaring-templates-the-display-property><span class=secno>5.
</span>Declaring templates: the ‘<a href="#display"><code
class=property>display</code></a>’ property</h2>
<p class=issue><a
href="http://www.w3.org/Style/CSS/Tracker/issues/123">ISSUE-123:</a> One
way to experiment safely with implementations before the specification
reaches Candidate Recommendation status is to add an identifier with a
vendor prefix somewhere in the value, e.g., ‘<code
class=css>display: -my-product "aa" "bc"</code>’ or ‘<code
class=css>display: -my-product("aa" "bc")</code>’.
<table class=propdef-extra>
<tbody>
<tr>
<td><em>Name:</em>
<td>‘<a href="#display"><code
class=property>display</code></a>’
<tr>
<td><em>New value:</em>
<td><a href="#ltdisplay-typegt0"><var><display-type></var></a>? &&
[ [ <a href="#ltstringgt"><var><string></var></a> [ / <a
href="#ltrow-heightgt"><var><row-height></var></a> ]? ]+ ] <a
href="#ltcol-widthgt"><var><col-width></var></a>*
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Computed value:</em>
<td>specified value
</table>
<p>A value of this form is called a <dfn id=template.>template.</dfn>
<p>An element with such a ‘<a href="#display"><code
class=property>display</code></a>’ value is similar to a table
element, in that its content is laid out in rows and columns. The two main
differences are that the number of rows and columns doesn't depend on the
content, but is fixed by the value of the property; and that the order of
the descendants in the source document may be different from the order in
which they appear in the rendered template.
<p>The <dfn id=ltdisplay-typegt><var><display-type></var></dfn> is
one of the following keywords. An omitted keyword is equivalent to
‘<code class=css>block</code>’.
<pre class=prod><dfn
id=ltdisplay-typegt0><var><display-type></var></dfn> = inline |
block | list-item | inline-block | table | inline-table |
table-row-group | table-header-group | table-footer-group | table-row
| table-column-group | table-column | table-cell | table-caption |
none</pre>
<dl>
<dt>‘<code class=css>inline</code>’
<dt>‘<code class=css>inline-block</code>’
<dt>‘<code class=css>inline-table</code>’
<dd>These three values are equivalent. The element is an
<em>inline-level</em> element.
<dt>‘<code class=css>list-item</code>’
<dd>The element is formatted as a list item. If the element has the value
‘<code class=css>inside</code>’ for its ‘<code
class=property>list-style-position</code>’, that ‘<code
class=css>inside</code>’ is treated as if it were ‘<code
class=css>outside</code>’.
<dt>‘<code class=css>block</code>’
<dt>‘<code class=css>table</code>’
<dd>These two values are equivalent.
<dt>‘<code class=css>table-row-group</code>’
<dt>‘<code class=css>table-header-group</code>’
<dt>‘<code class=css>table-footer-group</code>’
<dd>This creates a principal block-level box that is the template, with
around it an anonymous ‘<code class=css>table-row</code>’ box
and around it a box of the indicated type. Around it may be more
anonymous boxes according to the rules for <a
href="/TR/CSS2/tables.html#anonymous-boxes">Anonymous table objects</a>
<a href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>.
<dt>‘<code class=css>table-row</code>’
<dd>This creates a principal block-level box that is the template and
around it a ‘<code class=css>table-row</code>’ box. Around it
may be zero or more anonymous boxes according to the rules for <a
href="/TR/CSS2/tables.html#anonymous-boxes">Anonymous table objects</a>
<a href="#CSS21" rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>.
<dt>‘<code class=css>table-column-group</code>’
<dt>‘<code class=css>table-column</code>’
<dd>The template is ignored and the element is treated as an element of
the indicated type.
<dt>‘<code class=css>table-cell</code>’
<dd>The element is a table cell with a template.
<dt>‘<code class=css>table-caption</code>’
<dd>The element is a table caption with a template.
<dt>‘<code class=css>none</code>’
<dd>The template is ignored and the element is treated as for ‘<code
class=css>display: none</code>’.
</dl>
<p class=issue>Future display types added in other modules?
<p class=note>Note that ‘<a href="#display"><code
class=property>display</code></a>’ is extended to apply to ‘<a
href="#page"><code class=css>@page</code></a>’ rules as well and
that it has a different default there, viz., ‘<code
class=css>"@"</code>’. See <a href="#paged">“Templates in paged
media”</a> below.
<!-- If display becomes a shorthand for display-model and
display-role, explain that the former gets the template (and the
latter is inline or block depending on whether the inline
keyword is present). -->