@@ -71,7 +71,7 @@ Controlling Layout Modes: the 'display' property</h2>
71
71
72
72
<pre class="propdef">
73
73
Name : display
74
- Value : [ <<display-inside>> || <<display-outside>> || list-item ] <<display-box >> | <<display-internal >> | <<display-legacy>>
74
+ Value : [ <<display-inside>> || <<display-outside>> ] | <<display-listitem>> | <<display-internal >> | <<display-box >> | <<display-legacy>>
75
75
Initial : inline
76
76
Applies to : all elements
77
77
Inherited : no
@@ -82,7 +82,8 @@ Controlling Layout Modes: the 'display' property</h2>
82
82
83
83
<pre class='prod'>
84
84
<dfn><display-inside></dfn> = flow | flow-root | table | flex | grid | ruby ;
85
- <dfn><display-outside></dfn> = block | inline | run-in;
85
+ <dfn><display-outside></dfn> = block | inline | run-in ;
86
+ <dfn><display-listitem></dfn> = list-item && <<display-outside>> ? && [ flow | flow-root ]?
86
87
<dfn><display-box></dfn> = contents | none ;
87
88
<dfn><display-internal></dfn> = table-row-group | table-header-group |
88
89
table-footer-group | table-row | table-cell |
@@ -93,25 +94,25 @@ Controlling Layout Modes: the 'display' property</h2>
93
94
inline-table | inline-flex | inline-grid ;
94
95
</pre>
95
96
96
- The 'display' property defines how an element generates boxes,
97
- and how its boxes interact with the layout of their ancestors.\
98
- It defines two basic qualities of the boxes:
97
+ The 'display' property defines two basic qualities
98
+ of how an element generates boxes:
99
99
100
- * the <dfn export>inner display type</dfn> ,
100
+ * the <dfn export local-lt="inner" >inner display type</dfn> ,
101
101
which defines the kind of <a>formatting context</a> it generates,
102
102
dictating how its descendant boxes are laid out.
103
- * the <dfn export>outer display type</dfn> ,
103
+ * the <dfn export local-lt="outer" >outer display type</dfn> ,
104
104
which dictates how the box participates in its parent formatting context.
105
105
106
- Additional , it controls some other box-generation details,
106
+ Additionally , it controls some other box-generation details,
107
107
such as whether an element is a <a>list item</a> that generates a ''::marker'' pseudo-element.
108
108
109
- <h3>
109
+ <h3 id="major-layout-modes" >
110
110
The Major Layout Modes</h3>
111
111
112
112
The most common values of display correspond directly to the major layout algorithms in CSS.
113
113
114
- The <<display-inside>> keywords are defined as follows:
114
+ The <<display-inside>> keywords specify the element's <a>inner display type</a> ,
115
+ and are defined as follows:
115
116
116
117
<dl dfn-type="value" dfn-for="display, <display-inside> ">
117
118
<dt> <dfn>flow</dfn>
@@ -141,7 +142,8 @@ The Major Layout Modes</h3>
141
142
The element lays out its contents using ruby layout. [[!CSS3RUBY]]
142
143
</dl>
143
144
144
- The <<display-outside>> keywords are defined as follows:
145
+ The <<display-outside>> keywords specify the element's <a>outer display type</a> ,
146
+ and are defined as follows:
145
147
146
148
<dl dfn-type="value" dfn-for="display, <display-outside> ">
147
149
<dt> <dfn>block</dfn>
@@ -165,50 +167,36 @@ The Major Layout Modes</h3>
165
167
</dl>
166
168
167
169
If a <<display-inside>> is specified but <<display-outside>> is omitted,
168
- <<display-outside> > defaults to ''block'' ,
169
- except that ''ruby'' defaults to ''inline'' .
170
+ the element's <a>outer display type</a > defaults to ''block'' ,
171
+ except for ''ruby'' it defaults to ''inline'' .
170
172
171
173
If a <<display-outside>> is specified but <<display-inside>> is omitted,
172
- <<display-inside>> defaults to ''flow'' .
173
-
174
- The <dfn value for=display>list-item</dfn> keyword
175
- makes the element a <a>list item</a> .
176
- If <<display-inside>> is unspecified,
177
- it defaults to ''flow'' .
174
+ the element's <a>inner display type</a> defaults to ''flow'' .
175
+
176
+ The <dfn value for="display, <display-list-item>">list-item</dfn> keyword
177
+ makes the element generate a principal box of the specified type
178
+ together with a ''::marker'' pseudo-element box
179
+ (see <a href="http://www.w3.org/TR/CSS21/generate.html#lists">CSS 2.1§12.5 Lists</a> ).
180
+ If neither ''flow'' nor ''flow-root'' is specified,
181
+ the principal box's <a>inner display type</a> defaults to ''flow'' .
178
182
If <<display-outside>> is unspecified,
179
- it defaults to ''block'' .
180
-
181
- <h3>
182
- Box Generation</h3>
183
-
184
-
185
- <dl dfn-type=value dfn-for="display, <display-box> ">
186
- <dt> <dfn>contents</dfn>
187
- <dd>
188
- The element itself does not generate any boxes,
189
- but its children and pseudo-elements still generate boxes as normal.
190
- For the purposes of box generation and layout,
191
- the element must be treated as if it had been replaced with its children and pseudo-elements in the document tree.
183
+ the principal box's <a>outer display type</a> defaults to ''block'' .
192
184
193
- Issue: ''contents'' currently only has an effect on box generation and layout.
194
- Other things that care about the document tree are unaffected, like counter scopes.
195
- Is this what we want?
196
-
197
- <dt> <dfn>none</dfn>
198
- <dd>
199
- The element generates no boxes,
200
- and does not participate in any formatting context.
185
+ Issue: Update Lists module to be referenceable here instead.
201
186
202
- Note: This value exists for legacy reasons,
203
- and interacts with the separate 'box-suppress' property.
187
+ <h3 id="layout-specific-display">
188
+ Layout-Specific Display Types</h3>
204
189
205
- Advisement: It is recommended that 'box-suppress' be used instead of ''display: none'' ,
206
- so that the element's display type is automatically preserved
207
- for when it's no longer suppressed.
208
- </dl>
190
+ Some layout modes, such as ''table'' and ''ruby'' ,
191
+ have a complex internal structure,
192
+ with several different roles that their children and descendants can fill.
193
+ This section defines those "internal" 'display' values,
194
+ which only have meaning within a particular layout mode.
209
195
210
- <h3>
211
- Layout-Specific Display Types</h3>
196
+ Unless otherwise specified,
197
+ both the <a>inner display type</a> and the <a>outer display type</a>
198
+ of elements using these 'display' values
199
+ are set to the given keyword.
212
200
213
201
The <<display-internal>> keywords are defined as follows:
214
202
@@ -218,54 +206,114 @@ Layout-Specific Display Types</h3>
218
206
The element is an <dfn dfn>internal table element</dfn> ,
219
207
and participates in a table layout context. [[!CSS21]]
220
208
221
- ''table-cell'' and ''table-caption'' are <a>layout-specific leaf types</a> ;
222
- the rest are <a>layout-specific internal types</a> .
209
+ ''table-cell'' and ''table-caption'' have a ''flow-root'' <a>inner display type</a> .
223
210
224
211
<dt> <dfn>ruby-base</dfn> , <dfn>ruby-text</dfn> , <dfn>ruby-base-container</dfn> , <dfn>ruby-text-container</dfn>
225
212
<dd>
226
213
The element is an <dfn dfn>internal ruby element</dfn> ,
227
214
and participates in a ruby layout context. [[!CSS3RUBY]]
228
215
229
- ''ruby-base'' and ''ruby-text'' are <a>layout-specific leaf types</a> ;
230
- ''ruby-base-container'' and ''ruby-text-container'' are <a>layout-specific internal types</a> .
216
+ ''ruby-base'' and ''ruby-text'' have a ''flow-root'' <a>inner display type</a> .
231
217
</dl>
232
218
233
- The <<display-internal>> values are specialized for particular formatting contexts,
234
- and don't have meaning outside of those specific contexts:
219
+ Boxes with layout-specific display types generate anonymous wrapper boxes around themselves
220
+ when placed in an incompatible parent,
221
+ as defined by their respective specifications.
222
+
223
+ <div class='example'>
224
+ For example, Table Layout defines that a ''table-cell'' box
225
+ must have a ''table-row'' parent box.
226
+
227
+ If it is misparented, like so:
228
+
229
+ <pre class="lang-markup">
230
+ <div style="display:block;">
231
+ <div style="display:table-cell">...</div>
232
+ </div>
233
+ </pre>
234
+
235
+ It will generate wrapper boxes around itself,
236
+ producing a structure like:
237
+
238
+ <pre>
239
+ block box
240
+ └anonymous table box
241
+ └anonymous table-row-group box
242
+ └anonymous table-row box
243
+ └table-cell box
244
+ </pre>
245
+
246
+ Even if the parent is another <a>internal table element</a> ,
247
+ if it's not the <em> correct</em> one,
248
+ wrapper boxes will be generated.
249
+ For example, in the following markup:
250
+
251
+ <pre class="lang-markup">
252
+ <div style="display:table;">
253
+ <div style="display:table-row">
254
+ <div style="display:table-cell">...</div>
255
+ </div>
256
+ </div>
257
+ </pre>
258
+
259
+ Anonymous wrapper box generation will produce:
260
+
261
+ <pre>
262
+ table box
263
+ └anonymous table-row-group box
264
+ └table-row box
265
+ └table-cell box
266
+ </pre>
267
+
268
+ This "fix-up" ensures that the Table Layout has a predictable structure to operate on.
269
+ </div>
270
+
271
+ <h3 id="box-generation">
272
+ Box Generation</h3>
273
+
274
+ While 'display' can control the <em> types</em> of boxes an element will generate,
275
+ it can also control whether an element will generate any boxes at all.
276
+
277
+ Elements with either of these values do not have <a>inner</a> or <a>outer display types</a> ,
278
+ because they don't generate any boxes at all.
235
279
236
- <dl>
237
- <dt> <dfn>layout-specific internal types</dfn>
280
+ The <<display-box>> keywords are defined as follows:
281
+
282
+ <dl dfn-type=value dfn-for="display, <display-box> ">
283
+ <dt> <dfn>contents</dfn>
238
284
<dd>
239
- These display types require their parent and children to be of particular display types.
240
- For example, a ''table-row'' box requires its parent to be a <a>table row group box</a>
241
- and its children to be ''table-cell'' boxes.
285
+ The element itself does not generate any boxes,
286
+ but its children and pseudo-elements still generate boxes as normal.
287
+ For the purposes of box generation and layout,
288
+ the element must be treated as if it had been replaced with its children and pseudo-elements in the document tree.
289
+
290
+ Issue: ''contents'' currently only has an effect on box generation and layout.
291
+ Other things that care about the document tree are unaffected, like counter scopes.
292
+ Is this what we want?
242
293
243
- <dt> <dfn>layout-specific leaf types </dfn>
294
+ <dt> <dfn>none </dfn>
244
295
<dd>
245
- These display types require their parent to be of a particular display type,
246
- and automatically specify particular <a>inner display types</a> ,
247
- as defined by their respective specifications.
248
- For example, a ''table-caption'' box must have a ''table'' parent,
249
- and behaves as a ''block'' for its children.
250
- </dl>
296
+ The element and its descendants generates no boxes.
251
297
252
- Boxes with layout-specific types generate wrapper boxes around themselves
253
- when placed in an incompatible parent,
254
- as defined by their respective specifications.
298
+ Advisement: It is recommended that 'box-suppress' be used instead of ''display: none'' ,
299
+ so that the element's display type is automatically preserved
300
+ for when it's no longer suppressed.
301
+ </dl>
255
302
256
- <h3>
303
+ <h3 id='legacy-display' >
257
304
Legacy Display Values</h3>
258
305
306
+ CSS level 2 conflated the concepts of <a>inner</a> and <a>outer display types</a> ,
307
+ so that block-level and inline-level variants of the same layout mode were given separate names.
308
+ Now that 'display' separates those,
309
+ these legacy values can be mapped into the separate concepts they represent.
310
+
259
311
The <<display-legacy>> keywords are defined as follows:
260
312
261
313
<dl dfn-type=value dfn-for="display, <display-legacy> ">
262
314
<dt> <dfn>inline-block</dfn>
263
315
<dd>
264
- Behavas as ''inline flow-root'' .
265
-
266
- <dt> <dfn>inline-list-item</dfn>
267
- <dd>
268
- Behaves as ''inline list-item'' .
316
+ Behaves as ''inline flow-root'' .
269
317
270
318
<dt> <dfn>inline-table</dfn>
271
319
<dd>
@@ -285,8 +333,8 @@ Automatic Box Type Transformations</h3>
285
333
286
334
Some layout effects require <dfn export lt="blockify|blockification">blockification</dfn>
287
335
or <dfn export lt="inlinify|inlinification">inlinification</dfn> of the box type,
288
- causing the box’s <a>outer display type</a> , if it is not ''none'' or ''contents'' ,
289
- to compute to ''block'' or ''inline'' (respectively).
336
+ which sets the box’s <a>outer display type</a> , if it is not ''none'' or ''contents'' ,
337
+ to ''block'' or ''inline'' (respectively).
290
338
291
339
<div class='example'>
292
340
Some examples of this include:
@@ -298,9 +346,10 @@ Automatic Box Type Transformations</h3>
298
346
</ul>
299
347
</div>
300
348
301
- When a box is <a>inlinified</a> ,
302
- it recursively <a>inlinifies</a> all of its in-flow children
303
- unless it itself establishes a new formatting context,
349
+ If a box with a ''flow'' <a>inner display type</a> is <a>blockified</a> ,
350
+ its <a>inner display type</a> becomes ''flow-root'' .
351
+ If a box with a ''flow'' <a>inner display type</a> is <a>inlinified</a> ,
352
+ it recursively <a>inlinifies</a> all of its in-flow children,
304
353
so that no block-level descendants
305
354
break up the inline formatting context in which it participates.
306
355
@@ -311,6 +360,14 @@ Automatic Box Type Transformations</h3>
311
360
<h2 id='box-suppress'>
312
361
Controlling box generation: the 'box-suppress' property</h2>
313
362
363
+ ''display:none'' was historically used as a "toggle" to switch between displaying an element or not.
364
+ Making this reversible requires either setting up the CSS <a>cascade</a> properly,
365
+ or remembering what the display type was before it was set to ''none'' .
366
+ To make this common use-case easier,
367
+ the 'box-suppress' property was defined to do the same thing,
368
+ so that toggling whether or not an element displays
369
+ can now be done without affecting its layout type when it <em> is</em> displayed.
370
+
314
371
<pre class="propdef">
315
372
Name : box-suppress
316
373
Value : show | discard | hide
0 commit comments