forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOverview.src.html
More file actions
3163 lines (2532 loc) · 109 KB
/
Overview.src.html
File metadata and controls
3163 lines (2532 loc) · 109 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 http-equiv=content-type content="text/html; charset=utf-8">
<title>CSS Template Layout Module</title>
<link rel=stylesheet type="text/css" href="../default.css">
<link rel=stylesheet type="text/css"
href="http://www.w3.org/StyleSheets/TR/W3C-MO.css">
<div class=head>
<!--logo-->
<h1>CSS Template Layout Module</h1>
<h2 class="no-num no-toc">[LONGSTATUS] [DATE: 3 August 2004]</h2>
<dl>
<dt>This version: </dt>
<dd><a href="[VERSION]">
http://www.w3.org/TR/[YEAR]/ED-[SHORTNAME]-[CDATE]/</a>
<dt>Latest version:</dt>
<dd><a
href="[LATEST]">
http://www.w3.org/TR/css3-layout/</a>
<dt>Previous version:</dt>
<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:</dt>
<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>
<!--copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<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>A grid with four slots defined by 'display:
"aaaaaaa" "bccccdd"'.
</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 '::slot' 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>
<!--status-->
<p>This draft is related to the drafts about positoning with grid
units ('gr'), creating and naming grids and regions
[[CSS3-GRID-LAYOUT]], flexible <abbr title="Graphical User
Interfaces">GUIs</abbr> [[CSS3-FLEXBOX]], and tables [[!CSS3TBL]]. 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>
<!--toc-->
<h2 id=dependencies>Dependencies on other modules</h2>
<p>This CSS3 module depends on the following other CSS3 modules:
<ul>
<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="/TR/css3-values#strings">
<dfn><var><string></var></dfn></a> and <a
href="/TR/css3-values#length-value">
<dfn><var><length></var></dfn></a>.
<li><cite>CSS box module</cite> [[!CSS3BOX]] – properties
<dfn>width</dfn>, <dfn>height</dfn>, <dfn>float</dfn>,
<dfn>display</dfn> and <dfn>overflow</dfn>
<li><cite>CSS text layout</cite> [[!CSS3TEXTLAYOUT]] –
properties <dfn>direction</dfn> and <dfn>block-flow</dfn>
<li><cite>CSS positioning</cite> [[!CSS3POS]] – property
<dfn>z-index</dfn>
<li><cite>CSS paged media</cite> [[!CSS3PAGE]] – properties
<dfn>page-break-before</dfn>, <dfn>page-break-after</dfn> and
<dfn>page</dfn>; <a href="/TR/css3-page#page-area0"><dfn>page
area</dfn></a> (in particular its width & height).
<li><cite>CSS background and borders</cite> [[!CSS3BG]] –
property <dfn>background</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]] –
properties <dfn>break-before</dfn>, <dfn>break-after</dfn> and
<dfn>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 '::slot()'
pseudo-element”</a>).
<p>It has non-normative (informative) references to the following
other CSS3 modules:
<ul>
<li><cite>Selectors</cite> [[SELECT]]
</ul>
<p>See <a
href="http://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.
<h2>Introduction</h2>
<p><em>(This section is not normative.)</em>
<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 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 'position' property, which specifies
in this case into which slot of the template the element goes. The
template itself is specified on the 'display' 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 { 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 [[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 { 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 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 {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 [[!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 {display: "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: c}
.group > div + div {position: b}
.group > div + div + div {position: 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 {
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 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>
<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 src="regions-intro-rendering.png" alt="Image of a complex,
3-column layout" longdesc="regions-intro-rendering.desc">
<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>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 [[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="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>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>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>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>
[[CSS3-EXCLUSIONS]], is expected to allow floating elements to have
non-rectangular shapes and allow positioned elements to cause
wrap-around.
<h2>Declaring templates: the 'display' 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.,
'di
356A
splay: -my-product "aa" "bc"' or 'display: -my-product("aa"
"bc")'.
<table class=propdef-extra>
<tr>
<td><em>Name:</em>
<td>'display'
<tr>
<td><em>New value:</em>
<td><var><display-type></var>? && [ [ <var><string></var> [ /
<var><row-height></var> ]? ]+ ]
<var><col-width></var>*
<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>template.</dfn>
<p>An element with such a 'display' 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><var><display-type></var></dfn> is one of the
following keywords. An omitted keyword is equivalent to ''block''.
<pre class=prod><dfn><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>''inline''
<dt>''inline-block''
<dt>''inline-table''
<dd>These three values are equivalent. The element is
an <em>inline-level</em> element.
<dt>''list-item''
<dd>The element is formatted as a list item. If the element has the
value ''inside'' for its 'list-style-position', that ''inside'' is
treated as if it were ''outside''.
<dt&
D656
gt;''block''
<dt>''table''
<dd>These two values are equivalent.
<dt>''table-row-group''
<dt>''table-header-group''
<dt>''table-footer-group''
<dd>This creates a principal block-level box that is the template,
with around it an anonymous ''table-row'' 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> [[!CSS21]].
<dt>''table-row''
<dd>This creates a principal block-level box that is the template and
around it a ''table-row'' 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> [[!CSS21]].
<dt>''table-column-group''
<dt>''table-column''
<dd>The template is ignored and the element is treated as an element
of the indicated type.
<dt>''table-cell''
<dd>The element is a table cell with a template.
<dt>''table-caption''
<dd>The element is a table caption with a template.
<dt>''none''
<dd>The template is ignored and the element is treated as for
'display: none'.
</dl>
<p class=issue>Future display types added in other modules?
<p class=note>Note that 'display' is extended to apply to '@page'
rules as well and that it has a different default there, viz.,
''"@"''. 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). -->
<p>Each string consist of one or more at signs (“@”), letters (or
digits, see
<var><letter></var> below), periods
(“.”) and spaces. Each string represents
one row in the template, each character other than a space represents
one column in that row. Spaces have no meaning. They may be added for
readability.
<p>The symbols in the template have the following meaning
<dl>
<dt>a letter
<dd>slot for content.
<dt>@
<dd>(at sign) default slot for content.
<dt>.
<dd>(period) white-space.
</dl>
<p>Multiple identical letters in adjacent rows or columns form a
single <dfn>slot</dfn> that spans those rows and columns.
Ditto for multiple “@”s. Uppercase and lowercase are considered to be
the same letter (i.e., the template is case-insensitive).
<p>Non-rectangular slots and multiple slots with the same
letter are illegal. A template without any letter or
“@” is illegal. A template with more than one “@” slot is illegal.
These errors cause the declaration to be ignored.
<p class=note>Note: non-rectangular and disconnected regions
may be permitted in a future update of CSS.
<p>Rows with fewer columns than other rows are implicitly padded with
periods (“.”) (that will thus not contain any elements).
<p>Each slot (letter or “@”) acts as a block element for its
contents.
<p>Each <dfn><var><row-height></var></dfn> sets the
height of the preceding row. The default is ''auto''. The values can
be as follows:
<dl>
<dt><var><length></var>
<dd>An explicit height for that row. Negative values make the
template illegal. If the length is expressed in ''gr'' units, these
refer to the inherited grid, not the grid defined by the template
itself (see <a href="#gr-unit" >“Definition of the ''gr'' unit in a
template element”</a>).
<dt>auto
<dd>The row's height is determined by its contents. See the <a
href="#rowheight">algorithm</a> below.
<dt>*
<dd>(asterisk) All rows with an
asterisk will be of equal height. See the <a
href="#rowheight">algorithm</a> below.
</dl>
<p>Each <dfn><var><col-width></var></dfn> sets the width of a
column. If there are more <var><col-width></var>s then columns,
the last ones are ignored. If there are fewer, the missing ones are
assumed to be '*'. Each <var><col-width></var> can be one of the
following:
<dl>
<dt><var><length></var>
<dd>An explicit width for that column. Negative values make the
template illegal.
<dt>*
<dd>(asterisk.) All columns with a '*' have
the same width. See the <a href="#colwidth">algorithm</a> below.
<dt>max-content,
<dt>min-content
<dd>The column's width is determined by its contents. See the
<a href="#colwidth">algorithm</a> below.
<dt>minmax(<var>p</var>,<var>q</var>)
<dd>The column's width is constrained to be greater than or equal
to <var>p</var> and less than or equal to <var>q</var>. <var>p</var>
and <var>q</var> stand for [ <var><length></var> | max-content
| min-content | * ]. There may be white space around the <var>p</var>
and <var>q</var>. If <var>q</var> < <var>p</var>,
then <var>q</var> is ignored and
''minmax(<var>p</var>,<var>q</var>)'' is treated as
'minmax(<var>p</var>,<var>p</var>)'.
<dt>fit-content
<dd>Equivalent to 'minmax(min-content, max-content)'.
</dl>
<p class=note>Note that it is legal to specify no widths at all. In
that case, all columns have the same width.
<div class=issue>
<p><a href="http://www.w3.org/Style/CSS/Tracker/issues/127"
>ISSUE-127:</a>
It has been suggested that the template may become too verbose in
the case of column widths that are very small factions, e.g., a column
of 1/40th of the width:
<pre>display: "abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"</pre>
<p>Abbreviating this with percentages ('2.5% 97.5%') introduces an
opportunity for errors (e.g., '3% 98%' causes the template to be
rejected). Abbreviating with numbers,
<pre>display: "ab" * 39*</pre>
<p>(or even just '1 39') is safer. On the other hand, those 39
identical letters make it immediately clear what the intention
is…
<p>Percentages that do no sum to 100% need not be rejected, however:
they could be used to force overflow.
</div>
<p>The orientation of the template is independent of the writing mode
('direction' and 'block-flow' properties): the first string is the
topmost row and the first symbol in each string is the leftmost
column.
<div class=example>
<pre><style type="text/css">
div { display: ".aa..bb." }
p.left { position: a }
p.right { position: b }
</style>
<div>
<p class=left>Left column
<p class=right>Right column
</div></pre>
</div>
<p>An element with a template value for its 'display' property
is called a <dfn>template element</dfn>. An element's <dfn>template
ancestor</dfn> is defined (recursively) as follows:
<ul>
<li>if the element has 'position: fixed', 'position: absolute', a
value of 'float' that is not ''none'' or the element is the root
element, than it has no template ancestor.
<li>else, if the element's parent has a template as its
'display', then that parent is the element's template
ancestor.
<li>else, the element's template ancestor is the same as its
parent's template ancestor.
</ul>
<h2 id="slot-sizes">
Calculating the size of the grid</h2>
<p>For the purpose of the calculations below, each slot (letter or
“*”) in a grid has four dimensions associated wi
356A
th it, called
<var>MINW</var> (“minimum width”), <var>PREFW</var> (“preferred
width”), <var>MINH</var> (“minimum height”) and <var>PREFH</var>
(“preferred height”). We can think of them as the minimum and
preferred dimensions of the slot in isolation, i.e., if it wasn't
constrained by other slots in the same row or column. They are defined
as follows:
<dl>
<dt><var>MINW</var>
<dd>
<ul>
<li>If the slot spans only columns whose width does not depend on
the contents of the column (i.e., the column widths are specified
with only <var><length></var> values, '*',
<var><fraction></var> values, or any combination of those),
then <var>MINW</var> is 0. <span class=note>(Note that
<var><length></var> values can be specified with 'calc()'
as well, see [CSS3VALUES]].)</span>
<li>Otherwise, if the slot is <em>vertical,</em> then
<var>MINW</var> is the <em>block dimension</em> of the slot, plus
its horizontal padding, border and margin (i.e., any
'margin-left', 'margin-right', etc., that is set on it by means
of the '::slot()' pseudo-element). Any ''auto'' margins are
counted as 0 in this case.
<li>Otherwise, if the slot spans at least one column whose width
is specified as ''max-content'' (or 'minmax()' with a first
argument of 'max-content'), then <var>MINW</var> is the intrinsic
preferred width (see [[!CSS3BOX]]) of the slot plus its
horizontal margin, border and padding. Any ''auto'' margins are
counted as 0 in this case.
<li>Otherwise (i.e., the slot spans at least one column whose
width is specified as ''min-content'' or ''minmax()'' with a
first argument of ''min-content'', but no ''max-content'')
<var>MINW</var> is the intrinsic minimum width (see [[!CSS3BOX]]
of the slot, plus its horizontal padding, border and margin.
</ul>
<dt><var>PREFW</var>
<dd>
<ul>
<li>If the slot spans only columns whose width does not depend on
the contents of the column (i.e., the column widths are specified
with only <var><length></var> values, '*',
<var><fraction></var> values, or any combination of those),
then <var>PREFW</var> is infinite.
<li>Otherwise, if the slot is <em>vertical,</em> then
<var>PREFW</var> is the <em>block dimension</em> of the slot, plus
its horizontal padding, border and margin.
<li>Otherwise, if the slot spans at least one column whose width
is specified as ''max-content'' (or 'minmax()' with a first
argument of 'max-content'), then <var>PREFW</var> is the intrinsic
preferred width (see [[!CSS3BOX]]) of the slot plus its
horizontal margin, border and padding.
<li>Otherwise <var>PREFW</var> is the intrinsic minimum width
(see [[!CSS3BOX]] of the slot, plus its horizontal padding,
border and margin.
</ul>
<dt><var>MINH</var>
<dd>
<ul>
<li>If the slot spans only rows whose height does not depend on
the contents of the column (i.e., the row heights are specified
with only <var><length></var> values, '*',
<var><fraction></var> values, or any combination of those),
then <var>MINH</var> is 0.
<li>Otherwise, if the slot is <em>horizontal,</em> then
<var>MINH</var> is the <em>block dimension</em> of the slot, plus
its vertical padding, border and margin
<li>Otherwise, if the slot spans at least one row whose height is
specified as ''max-content'' (or 'minmax()' with a first argument
of 'max-content'), then <var>MINH</var> is the intrinsic
preferred height (see [[!CSS3BOX]]) of the slot plus its vertical
margin, border and padding.
<li>Otherwise <var>MINH</var> is the intrinsic minimum height
(see [[!CSS3BOX]] of the slot, plus its vertical padding, border
and margin.
</ul>
<dt><var>PREFH</var>
<dd>
<ul>
<li>If the slot spans only rows whose height does not depend on
the contents of the column (i.e., the row heights are specified
with only <var><length></var> values, '*',
<var><fraction></var> values, or any combination of those),
then <var>MINH</var> is infinite.
<li>Otherwise, if the slot is <em>horizontal,</em> then
<var>PREFH</var> is the <em>block dimension</em> of the slot, plus
its vertical padding, border and margin
<li>Otherwise, if the slot spans at least one row whose height is
specified as ''max-content'' (or 'minmax()' with a first argument
of 'max-content'), then <var>PREFH</var> is the intrinsic
preferred height (see [[!CSS3BOX]]) of the slot plus its vertical
margin, border and padding.
<li>Otherwise <var>PREFH</var> is the intrinsic minimum height
(see [[!CSS3BOX]] of the slot, plus its vertical padding, border
and margin.
</ul>
</dl>
<div class=example>
<p>For example, the <var>MINW</var> values of the slots in this grid
<pre>grid: " a a ."
" b . c"
fit-content * 10em</pre>
<p>are as follows:
<dl>
<dt>a <dd>'min-content' (because the slot spans at least one
column with a width specified as 'min-content' or 'fit-content').
<dt>b <dd>'min-content' (ditto).
<dt>c <dd>0 (because the slot spans only columns with a width that
is independent of the content).
</dl>
</div>
<p>The UA must choose the widths and heights of all columns and rows
such that the following constraints are satisfied.
<ol>
<!-- Constraints relating to the element's own width and
height. These constraints may be dropped if overconstrained -->
<li>