-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.bs
More file actions
executable file
·347 lines (274 loc) · 11.6 KB
/
Overview.bs
File metadata and controls
executable file
·347 lines (274 loc) · 11.6 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
<h1>CSS Display Module Level 3</h1>
<pre class='metadata'>
Status: ED
ED: http://dev.w3.org/csswg/css-display
Shortname: css-display
Group: csswg
Level: 3
Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/
Abstract: This module contains the features of CSS relating to the 'display' property and other box-generation details.
Ignored Terms: show, display-model, display-role
</pre>
<h2 id="intro">
Introduction</h2>
<p><em>This section is not normative.</em>
The 'display' property, introduced in CSS 2.1,
defines what kind of boxes an element generates
(and whether it generates boxes at all),
and how it lays out its contents.
These concepts are actually rather independent,
though they're conflated by the 'display' property.
This causes some pain when a property value intended to affect one aspect
(such as setting an element to ''display:none'' to suppress box generation)
affects another aspect
(such as losing the memory of what it was <em>before</em> ''display:none'',
so that it can be set back to that value later).
This specification subsumes the CSS 2.1 definition of the 'display' property,
and redefines it to be a shorthand property for a small family of longhands,
each controlling an independent aspect of an element's "display".
<h3 id="placement">
Module interactions</h3>
This specification transforms the 'display' property into a shorthand property,
and defines several longhand properties that it expands into or effects.
This module replaces and extends the definition of the 'display' property defined in [[!CSS21]] section 9.2.4.
None of the properties in this module apply to the <code>::first-line</code> or <code>::first-letter</code> pseudo-elements.
<h3 id="values">
Values</h3>
This specification follows the
<a href="http://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.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification also accept the
<a href="http://www.w3.org/TR/css3-values/#common-keywords">CSS-wide keywords</a>
as their property value. For readability it has not been repeated explicitly.
<h2 id='the-display-properties'>
The Display Properties</h2>
The 'display' shorthand and its associated family of properties control the layout mode of elements
(how the element determines the sizes and positions of itself and its descendants),
and what boxes they and their descendants generate.
<h3 id='the-display-inside'>
Setting the layout mode: the 'display-inside' property</h3>
<pre clas="propdef">
Name: display-inside
Value: auto | block | table | flex | grid
Initial: auto
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: a keyword
Media: all
</pre>
<dl dfn-type="value" dfn-for="display-inside">
<dt><dfn>auto</dfn>
<dd>
If the element's computed 'display-outside' value is ''inline-level'',
the element is an inline element,
and lays out its contents using inline layout. [[!CSS21]]
If the element's computed 'display-outside' value is ''table-row-group'', ''table-header-group'', ''table-footer-group'', ''table-row'', ''table-column-group'', or ''table-column'',
this elements acts as normal for its given 'display-outside' value.
Otherwise, this value computes to ''display-inside/block''.
<dt><dfn>block</dfn>
<dd>
The element lays out its contents using block layout. [[!CSS21]]
<dt><dfn>table</dfn>
<dd>
The element lays out its contents using table layout. [[!CSS21]]
<dt><dfn>flex</dfn>
<dd>
The element lays out its contents using flex layout. [[!CSS3-FLEXBOX]]
<dt><dfn>grid</dfn>
<dd>
The element lays out its contents using grid layout. [[!CSS3-GRID-LAYOUT]]
</dl>
<h3 id='the-display-outside'>
Interacting with the layout mode: the 'display-outside' property</h3>
<pre class="propdef">
Name: display-outside
Value: block-level | inline-level | none | table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption
Initial: inline-level
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: as specified
Media: all
</pre>
<dl dfn-type="value" dfn-for="display-outside">
<dt><dfn>block-level</dfn>
<dd>
The element is block-level,
and participates in a block formatting context.
Other formatting contexts,
such as flex formatting contexts,
may also work with block-level elements. [[!CSS21]]
<dt><dfn>inline-level</dfn>
<dd>
The element is inline-level,
and participates in an inline formatting context. [[!CSS21]]
<dt><dfn>none</dfn>
<dd>
The element generates no boxes,
and does not participate in any formatting context.
Note: This value exists for legacy reasons,
and interacts with the separate 'display-box' property.
It is recommended that 'display-box' be used to suppress an element,
so that the element's display type is automatically preserved
for when it's no longer suppressed.
<dt><dfn>table-row-group</dfn>, <dfn>table-header-group</dfn>, <dfn>table-footer-group</dfn>, <dfn>table-row</dfn>, <dfn>table-cell</dfn>, <dfn>table-column-group</dfn>, <dfn>table-column</dfn>, <dfn>table-caption</dfn>
<dd>
The element is an internal table element,
and participates in a table layout context. [[!CSS21]]
</dl>
<p class='issue'>
Do we need special bits about some of the interactions with 'display-inside'?
For example, how ''display:inline-level block;'' works?
Or does that fall out of what exists,
and the definitions of Block Layout in 2.1?
(...or a new Block Layout spec, explaining all the 2.1 stuff more sanely?)
<p class='issue'>
Is <a href="http://lists.w3.org/Archives/Public/www-style/2012Jul/0450.html">fantasai's proposal for a run-in model</a> sane enough to include in this spec?
<h3 id='the-display-extras'>
Additional stuff: the 'display-extras' property</h3>
<pre class="propdef">
Name: display-extras
Value: none | list-item
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: as specified
Media: all
</pre>
<dl dfn-type="value" dfn-for="display-extras">
<dt><dfn>list-item</dfn>
<dd>
The element generates a <code>::marker</code> pseudo-element
and is considered a <a>list item</a>.
</dl>
<p class='issue'>
This property is probably dumb,
and at the very least has a dumb name.
Better names?
If I define more one-off weird box-generation details like this,
should I merge them into a single "extras" property like this,
or just have them all be separate properties?
<h3 id='the-display'>
The 'display' shorthand property</h3>
<pre class="propdef">
Name: display
Value: inline | block | list-item | inline-list-item | inline-block | table | inline-table | table-cell | table-caption | flex | inline-flex | grid | inline-grid | [ <<'display-inside'>> || <<'display-outside'>> || <<'display-extras'>> ]
Initial: see individual properties
Applies to: see individual properties
Inherited: see individual properties
Computed value: see individual properties
Animatable: see individual properties
Media: see individual properties
</pre>
<p>
The single-keyword values listed explicitly in the grammar above are handled specially,
for legacy reasons.
All other single-keyword values,
and all other values in general,
are handled as normal for shorthands.
<p class='issue'>
The general rule for new layout modes seems to be that they're block-level by default.
However, this conflicts with the default value of 'display-outside', which is ''inline-level''.
What's the best way to address this?
Simplest answer is to just expand this list of special values as we go along.
Another possibility is to magic up the expansion in a different way,
so that if the value is just a 'display-inside' keyword,
'display-outside' defaults to ''block-level''.
If the latter is chosen, we could remove several more of the special expansions below
(all the ones that are identical to a 'display-inside' value).
Note: Several of the "special" expansions below are actually just what the shorthand would expand to normally.
They're included here for clarity,
as they're very familiar from long usage in CSS 2.1,
before the 'display' property became a shorthand.
<dl dfn-type="value" dfn-for="display">
<dt><dfn>inline</dfn>
<dd>
Expands identically to ''inline-level auto''.
<dt><dfn>block</dfn>
<dd>
Expands identically to ''block-level block''.
<dt><dfn>list-item</dfn>
<dd>
Expands identically to ''block-level block list-item''.
<dt><dfn>inline-list-item</dfn>
<dd>
Expands identically to ''inline-level block list-item''.
<dt><dfn>inline-block</dfn>
<dd>
Expands identically to ''inline-level block''.
<dt><dfn>table</dfn>
<dd>
Expands identically to ''block-level table''.
<dt><dfn>inline-table</dfn>
<dd>
Expands identically to ''inline-level table''.
<dt><dfn>table-caption</dfn>
<dd>
Expands identically to ''table-caption block''.
<dt><dfn>table-cell</dfn>
<dd>
Expands identically to ''table-cell block''.
<dt><dfn>flex</dfn>
<dd>
Expands identically to ''block-level flex''.
<dt><dfn>inline-flex</dfn>
<dd>
Expands identically to ''inline-level flex''.
<dt><dfn>grid</dfn>
<dd>
Expands identically to ''block-level grid''.
<dt><dfn>inline-grid</dfn>
<dd>
Expands identically to ''inline-level grid''.
</dl>
<h2 id='the-display-box'>
Controlling box generation: the 'display-box' property</h2>
<pre class="propdef">
Name: display-box
Value: normal | none | contents
Initial: normal
Applies to: all elements
Inherited: no
Percentages: n/a
Computed value: see prose
Media: all
</pre>
The 'display-box' property is not part of the 'display' shorthand,
so that 'display' can be safely set without accidentally overriding whether an element is being suppressed or not.
If the computed value of 'display-outside' is ''display-outside/none'',
the computed value of 'display-box' is ''display-box/none''.
Otherwise, the computed value is the specified value.
<dl dfn-type="value" dfn-for="box">
<dt><dfn>normal</dfn>
<dd>
The element generates boxes as normal,
per its other 'display-*' properties.
<dt><dfn>none</dfn>
<dd>
The element generates no boxes at all.
<dt><dfn>contents</dfn>
<dd>
The element itself does not generate any boxes,
but its children and pseudo-elements still generate boxes as normal.
For the purposes of box generation and layout,
the element must be treated as if it had been replaced with its children and pseudo-elements in the document tree.
</dl>
<p class='issue'>
Is there a need for a value that suppresses box generation for layout purposes,
but still generates them for the purposes of animations/counters/etc.?
<p class='issue'>
''contents'' currently only has an effect on box generation and layout.
Other things that care about the document tree are unaffected, like counter scopes.
Is this what we want?
<h2 class=no-num id="acknowledgments">
Acknowledgments</h2>
We would like to thank the many people who have attempted to separate out the disparate details of box generation over the years,
most particularly Bert Bos,
whose last attempt with 'display-model' and 'display-role' didn't get anywhere,
but primed us for the current spec.
We would also like to thank the many JavaScript libraries such as jQuery which have hacked around the "what 'display' should I give it when you call .show()?" problem, making it extremely clear that something needed to be done on our part.