Skip to content

Commit cd7a900

Browse files
committed
[css-display] More work getting all the terminology consistent through the spec.
1 parent 7a78730 commit cd7a900

File tree

1 file changed

+137
-80
lines changed

1 file changed

+137
-80
lines changed

css-display/Overview.bs

Lines changed: 137 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Controlling Layout Modes: the 'display' property</h2>
7171

7272
<pre class="propdef">
7373
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>>
7575
Initial: inline
7676
Applies to: all elements
7777
Inherited: no
@@ -82,7 +82,8 @@ Controlling Layout Modes: the 'display' property</h2>
8282

8383
<pre class='prod'>
8484
<dfn>&lt;display-inside></dfn> = flow | flow-root | table | flex | grid | ruby ;
85-
<dfn>&lt;display-outside></dfn> = block | inline | run-in;
85+
<dfn>&lt;display-outside></dfn> = block | inline | run-in ;
86+
<dfn>&lt;display-listitem></dfn> = list-item && <<display-outside>>? && [ flow | flow-root ]?
8687
<dfn>&lt;display-box></dfn> = contents | none ;
8788
<dfn>&lt;display-internal></dfn> = table-row-group | table-header-group |
8889
table-footer-group | table-row | table-cell |
@@ -93,25 +94,25 @@ Controlling Layout Modes: the 'display' property</h2>
9394
inline-table | inline-flex | inline-grid ;
9495
</pre>
9596

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:
9999

100-
* the <dfn export>inner display type</dfn>,
100+
* the <dfn export local-lt="inner">inner display type</dfn>,
101101
which defines the kind of <a>formatting context</a> it generates,
102102
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>,
104104
which dictates how the box participates in its parent formatting context.
105105

106-
Additional, it controls some other box-generation details,
106+
Additionally, it controls some other box-generation details,
107107
such as whether an element is a <a>list item</a> that generates a ''::marker'' pseudo-element.
108108

109-
<h3>
109+
<h3 id="major-layout-modes">
110110
The Major Layout Modes</h3>
111111

112112
The most common values of display correspond directly to the major layout algorithms in CSS.
113113

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:
115116

116117
<dl dfn-type="value" dfn-for="display, <display-inside>">
117118
<dt><dfn>flow</dfn>
@@ -141,7 +142,8 @@ The Major Layout Modes</h3>
141142
The element lays out its contents using ruby layout. [[!CSS3RUBY]]
142143
</dl>
143144

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:
145147

146148
<dl dfn-type="value" dfn-for="display, <display-outside>">
147149
<dt><dfn>block</dfn>
@@ -165,50 +167,36 @@ The Major Layout Modes</h3>
165167
</dl>
166168

167169
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''.
170172

171173
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''.
178182
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''.
192184

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.
201186

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>
204189

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.
209195

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.
212200

213201
The <<display-internal>> keywords are defined as follows:
214202

@@ -218,54 +206,114 @@ Layout-Specific Display Types</h3>
218206
The element is an <dfn dfn>internal table element</dfn>,
219207
and participates in a table layout context. [[!CSS21]]
220208

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>.
223210

224211
<dt><dfn>ruby-base</dfn>, <dfn>ruby-text</dfn>, <dfn>ruby-base-container</dfn>, <dfn>ruby-text-container</dfn>
225212
<dd>
226213
The element is an <dfn dfn>internal ruby element</dfn>,
227214
and participates in a ruby layout context. [[!CSS3RUBY]]
228215

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>.
231217
</dl>
232218

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+
&lt;div style="display:block;">
231+
&lt;div style="display:table-cell">...&lt;/div>
232+
&lt;/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+
&lt;div style="display:table;">
253+
&lt;div style="display:table-row">
254+
&lt;div style="display:table-cell">...&lt;/div>
255+
&lt;/div>
256+
&lt;/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.
235279

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>
238284
<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?
242293

243-
<dt><dfn>layout-specific leaf types</dfn>
294+
<dt><dfn>none</dfn>
244295
<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.
251297

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>
255302

256-
<h3>
303+
<h3 id='legacy-display'>
257304
Legacy Display Values</h3>
258305

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+
259311
The <<display-legacy>> keywords are defined as follows:
260312

261313
<dl dfn-type=value dfn-for="display, <display-legacy>">
262314
<dt><dfn>inline-block</dfn>
263315
<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''.
269317

270318
<dt><dfn>inline-table</dfn>
271319
<dd>
@@ -285,8 +333,8 @@ Automatic Box Type Transformations</h3>
285333

286334
Some layout effects require <dfn export lt="blockify|blockification">blockification</dfn>
287335
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).
290338

291339
<div class='example'>
292340
Some examples of this include:
@@ -298,9 +346,10 @@ Automatic Box Type Transformations</h3>
298346
</ul>
299347
</div>
300348

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,
304353
so that no block-level descendants
305354
break up the inline formatting context in which it participates.
306355

@@ -311,6 +360,14 @@ Automatic Box Type Transformations</h3>
311360
<h2 id='box-suppress'>
312361
Controlling box generation: the 'box-suppress' property</h2>
313362

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+
314371
<pre class="propdef">
315372
Name: box-suppress
316373
Value: show | discard | hide

0 commit comments

Comments
 (0)