8000 [css-display] Revise/clean up the 'display' merger, take 1. · w3c/csswg-drafts@ef8d548 · GitHub
Skip to content

Commit ef8d548

Browse files
committed
[css-display] Revise/clean up the 'display' merger, take 1.
1 parent aec6064 commit ef8d548

1 file changed

Lines changed: 107 additions & 88 deletions

File tree

css-display/Overview.bs

Lines changed: 107 additions & 88 deletions
< 9F6F /tr>
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,19 @@ Values</h3>
9393

9494
This specification follows the
9595
<a href="http://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
96-
definition conventions</a> from [[!CSS21]]. Value types not defined in
97-
this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
98-
Other CSS modules may expand the definitions of these value types.
96+
definition conventions</a> from [[!CSS21]].
9997

10098
In addition to the property-specific values listed in their definitions,
10199
all properties defined in this specification also accept the
102100
<a href="http://www.w3.org/TR/css3-values/#common-keywords">CSS-wide keywords</a>
103101
as their property value. For readability it has not been repeated explicitly.
104102

105103
<h2 id='the-display-properties'>
106-
Controlling Layout Modes: the 'display' property</h2>
107-
108-
The 'display' property controls the layout mode of elements
109-
(how the element determines the sizes and positions of itself and its descendants),
110-
and what boxes they and their descendants generate.
104+
Box Layout Modes: the 'display' property</h2>
111105

112106
<pre class="propdef">
113107
Name: display
114-
Value: [ <<display-inside>> || <<display-outside>> ] | <<display-listitem>> | <<display-internal>> | <<display-box>> | <<display-legacy>>
108+
Value: [ <<display-outside>> || <<display-inside>> ] | <<display-listitem>> | <<display-internal>> | <<display-box>> | <<display-legacy>>
115109
Initial: inline
116110
Applies to: all elements
117111
Inherited: no
@@ -120,123 +114,151 @@ Controlling Layout Modes: the 'display' property</h2>
120114
Media: all
121115
</pre>
122116

123-
The 'display' property, introduced in CSS 2.1,
124-
defines what kind of boxes an element generates
125-
(and whether it generates boxes at all),
126-
and how it lays out its contents.
117+
The 'display' property defines two basic qualities
118+
of how an element generates boxes:
119+
120+
* the <dfn export local-lt="inner">inner display type</dfn>,
121+
which defines the kind of <a>formatting context</a> it generates,
122+
dictating how its descendant boxes are laid out.
123+
* the <dfn export local-lt="outer">outer display type</dfn>,
124+
which dictates how the box participates in its parent formatting context.
125+
126+
Some 'display' values have additional side-effects:
127+
such as ''list-item'', which also generates a ''::marker'' pseudo-element,
128+
and ''none'', which causes the element's entire subtree to be left out of the box tree.
129+
130+
Values are defined as follows:
127131

128132
<pre class='prod'>
129-
<dfn>&lt;display-inside></dfn> = flow | flow-root | table | flex | grid | ruby ;
130133
<dfn>&lt;display-outside></dfn> = block | inline | run-in ;
134+
<dfn>&lt;display-inside></dfn> = flow | flow-root | table | flex | grid | ruby ;
131135
<dfn>&lt;display-listitem></dfn> = list-item && <<display-outside>>? && [ flow | flow-root ]?
132-
<dfn>&lt;display-box></dfn> = contents | none ;
133136
<dfn>&lt;display-internal></dfn> = table-row-group | table-header-group |
134137
table-footer-group | table-row | table-cell |
135138
table-column-group | table-column | table-caption |
136139
ruby-base | ruby-text | ruby-base-container |
137140
ruby-text-container ;
141+
<dfn>&lt;display-box></dfn> = contents | none ;
138142
<dfn>&lt;display-legacy></dfn> = inline-block | inline-list-item |
139143
inline-table | inline-flex | inline-grid ;
140144
</pre>
141145

142-
The 'display' property defines two basic qualities
143-
of how an element generates boxes:
146+
<h3 id="outer-role">
147+
Outer Display Roles for Flow Layout: the ''block'', ''inline'', and ''run-in'' keywords</h3>
144148

145-
* the <dfn export local-lt="inner">inner display type</dfn>,
146-
which defines the kind of <a>formatting context</a> it generates,
147-
dictating how its descendant boxes are laid out.
148-
* the <dfn export local-lt="outer">outer display type</dfn>,
149-
which dictates how the box participates in its parent formatting context.
149+
The <<display-outside>> keywords specify the element's <a>outer display type</a>,
150+
which is essentially its role in <a>flow layout</a>.
151+
They are defined as follows:
150152

151-
Additionally, it controls some other box-generation details,
152-
such as whether an element is a <a>list item</a> that generates a ''::marker'' pseudo-element.
153+
<dl dfn-type="value" dfn-for="display, <display-outside>">
154+
<dt><dfn>block</dfn>
155+
<dd>
156+
The element generates a <dfn dfn>block-level box</dfn>. [[!CSS21]]
153157

154-
<h3 id="major-layout-modes">
155-
The Major Layout Modes</h3>
158+
<dt><dfn>inline</dfn>
159+
<dd>
160+
The element generates an <dfn dfn>inline-level box</dfn>. [[!CSS21]]
156161

157-
The most common values of display correspond directly to the major layout algorithms in CSS.
162+
<dt><dfn>run-in</dfn>
163+
<dd>
164+
The element generates a <a>run-in box</a>.
165+
Run-in elements act like inlines or blocks,
166+
depending on the surrounding elements.
167+
See [[#run-in]] for details.
168+
</dl>
169+
170+
If a <<display-outside>> value is specified but <<display-inside>> is omitted,
171+
the element's <a>inner display type</a> defaults to ''flow''.
172+
173+
<h3 id="inner-model">
174+
Inner Display Layout Models: the ''flow'', ''flow-root'', ''table'', ''grid'', and ''ruby'' keywords</h3>
158175

159176
The <<display-inside>> keywords specify the element's <a>inner display type</a>,
160-
and are defined as follows:
177+
which defines the type of formatting context that lays out its contents.
178+
They are defined as follows:
161179

162180
<dl dfn-type="value" dfn-for="display, <display-inside>">
163181
<dt><dfn>flow</dfn>
164182
<dd>
165-
The element lays out its contents using flow layout.
166-
(Also known as "block" or "inline" layout.) [[!CSS21]]
183+
The element lays out its contents using <dfn dfn>flow layout</dfn>
184+
(<a href="http://www.w3.org/TR/CSS21/visuren.html">block-and-inline layout</a>).
185+
186+
If its <a>outer display type</a> is ''inline'' or ''run-in'',
187+
and it is participating in a
188+
<a href="http://www.w3.org/TR/CSS21/visuren.html#inline-formatting">block</a>
189+
or <a href="http://www.w3.org/TR/CSS21/visuren.html#inline-formatting">inline</a>
190+
formatting context,
191+
then it generates an <a href="http://www.w3.org/TR/CSS21/visuren.html#inline-box">inline box</a>.
192+
193+
Otherwise it generates a <a>block container</a> box.
194+
195+
Depending on the value of other properties (such as 'position', 'float', or 'overflow')
196+
and whether it is itself participating in a block or inline <a>formatting context</a>,
197+
it either establishes a new <a href="http://www.w3.org/TR/CSS21/visuren.html#block-formatting">block formatting context</a> for its contents
198+
or integrates its contents into its parent <a>formatting context</a>.
199+
See <a href="http://www.w3.org/TR/CSS21/visuren.html">CSS2.1 Chapter 9</a>. [[!CSS21]]
167200

168201
<dt><dfn>flow-root</dfn>
169202
<dd>
170-
The element lays out its contents using flow layout,
171-
and establishes a <a>block formatting context</a>. [[!CSS21]]
203+
The element generates a <a>block container</a> box,
204+
and lays out its contents using <a>flow layout</a>.
205+
It always establishes a new <a href="http://www.w3.org/TR/CSS21/visuren.html#block-formatting">block formatting context</a> for its contents. [[!CSS21]]
172206

173207
<dt><dfn>table</dfn>
174208
<dd>
175-
The element lays out its contents using table layout. [[!CSS21]]
209+
The element generates a principal <i>table wrapper box</i>
210+
containing an additionally-generated <i>table box</i>,
211+
and establishes a <i>table formatting context</i>. [[!CSS21]]
176212

177213
<dt><dfn>flex</dfn>
178214
<dd>
179-
The element lays out its contents using flex layout. [[!CSS3-FLEXBOX]]
215+
The element generates a principal <a>flex container</a> box
216+
and establishes a <a>flex formatting context</a>. [[!CSS3-FLEXBOX]]
180217

181218
<dt><dfn>grid</dfn>
182219
<dd>
183-
The element lays out its contents using grid layout. [[!CSS3-GRID-LAYOUT]]
220+
The element generates a principal <a>grid container</a> box,
221+
and establishes a <a>grid formatting context</a>. [[!CSS3-GRID-LAYOUT]]
184222

185223
<dt><dfn>ruby</dfn>
186224
<dd>
187-
The element lays out its contents using ruby layout. [[!CSS3RUBY]]
225+
The element generates a principal <a>ruby container</a> box,
226+
and establishes a <a>ruby formatting context</a>. [[!CSS3RUBY]]
188227
</dl>
189228

190-
The <<display-outside>> keywords specify the element's <a>outer display type</a>,
191-
and are defined as follows:
229+
If a <<display-inside>> value is specified but <<display-outside>> is omitted,
230+
the element's <a>outer display type</a> defaults to ''block''--
231+
except for ''ruby'', which defaults to ''inline''.
192232

193-
<dl dfn-type="value" dfn-for="display, <display-outside>">
194-
<dt><dfn>block</dfn>
195-
<dd>
196-
The element generates a <dfn dfn>block-level box</dfn>,
197-
and participates in a block formatting context.
198-
Other formatting contexts,
199-
such as flex formatting contexts,
200-
may also work with block-level elements. [[!CSS21]]
201-
202-
<dt><dfn>inline</dfn>
203-
<dd>
204-
The element generates an <dfn dfn>inline-level box</dfn>. [[!CSS21]]
205-
206-
<dt><dfn>run-in</dfn>
207-
<dd>
208-
The element generates a <a>run-in box</a>.
209-
Run-in elements act like inlines or blocks,
210-
depending on the surrounding elements.
211-
See [[#run-in]] for details.
212-
</dl>
213-
214-
If a <<display-inside>> is specified but <<display-outside>> is omitted,
215-
the element's <a>outer display type</a> defaults to ''block'',
216-
except for ''ruby'' it defaults to ''inline''.
217-
218-
If a <<display-outside>> is specified but <<display-inside>> is omitted,
219-
the element's <a>inner display type</a> defaults to ''flow''.
233+
<h3 id="list-items">
234+
Generating Marker Boxes: the ''list-item'' keyword</h3>
220235

221236
The <dfn value for="display, <display-list-item>">list-item</dfn> keyword
222-
makes the element generate a principal box of the specified type
223-
together with a ''::marker'' pseudo-element box
224-
(see <a href="http://www.w3.org/TR/CSS21/generate.html#lists">CSS 2.1§12.5 Lists</a>).
225< 9E69 code>-
If neither ''flow'' nor ''flow-root'' is specified,
237+
causes the element to generate a ''::marker'' pseudo-element box [[!CSS-PSEUDO-4]]
238+
with the content specified by its 'list-style' properties
239+
(<a href="http://www.w3.org/TR/CSS21/generate.html#lists">CSS 2.1§12.5 Lists</a>) [[!CSS21]]
240+
together with a principal box of the specified type for its own contents.
241+
242+
If no <<display-inside>> value is specified,
226243
the principal box's <a>inner display type</a> defaults to ''flow''.
227-
If <<display-outside>> is unspecified,
244+
If no <<display-outside>> value is specified,
228245
the principal box's <a>outer display type</a> defaults to ''block''.
229246

230-
Issue: Update Lists module to be referenceable here instead.
247+
Note: In this level, as restricted in the grammar,
248+
a list-item can only be a block box,
249+
a block formatting context root box,
250+
an inline box,
251+
or an inline-block box.
252+
This restriction may be relaxed in a future level of this module.
231253

232254
<h3 id="layout-specific-display">
233-
Layout-Specific Display Types</h3>
255+
Layout-Internal Display Types: the ''table-*'' and ''ruby-*'' keywords</h3>
234256

235-
Some layout modes, such as ''table'' and ''ruby'',
257+
Some layout models, such as ''table'' and ''ruby'',
236258
have a complex internal structure,
237259
with several different roles that their children and descendants can fill.
238260
This section defines those "internal" 'display' values,
239-
which only have meaning within a particular layout mode.
261+
which only have meaning within that particular layout mode.
240262

241263
Unless otherwise specified,
242264
both the <a>inner display type</a> and the <a>outer display type</a>
@@ -258,15 +280,15 @@ Layout-Specific Display Types</h3>
258280
The element is an <dfn dfn>internal ruby element</dfn>,
259281
and participates in a ruby layout context. [[!CSS3RUBY]]
260282

261-
''ruby-base'' and ''ruby-text'' have a ''flow-root'' <a>inner display type</a>.
283+
''ruby-base'' and ''ruby-text'' have a ''flow'' <a>inner display type</a>.
262284
</dl>
263285

264286
Boxes with layout-specific display types generate anonymous wrapper boxes around themselves
265287
when placed in an incompatible parent,
266288
as defined by their respective specifications.
267289

268290
<div class='example'>
269-
For example, Table Layout defines that a ''table-cell'' box
291+
For example, Table Layout requires that a ''table-cell'' box
270292
must have a ''table-row'' parent box.
271293

272294
If it is misparented, like so:
@@ -310,18 +332,15 @@ Layout-Specific Display Types</h3>
310332
└table-cell box
311333
</pre>
312334

313-
This "fix-up" ensures that the Table Layout has a predictable structure to operate on.
335+
This "fix-up" ensures that table layout has a predictable structure to operate on.
314336
</div>
315337

316338
<h3 id="box-generation">
317-
Box Generation</h3>
339+
Box Generation: the ''none'' and ''contents'' keywords</h3>
318340

319341
While 'display' can control the <em>types</em> of boxes an element will generate,
320342
it can also control whether an element will generate any boxes at all.
321343

322-
Elements with either of these values do not have <a>inner</a> or <a>outer display types</a>,
323-
because they don't generate any boxes at all.
324-
325344
The <<display-box>> keywords are defined as follows:
326345

327346
<dl dfn-type=value dfn-for="display, <display-box>">
@@ -345,15 +364,15 @@ Box Generation</h3>
345364
for when it's no longer suppressed.
346365
</dl>
347366

348-
<h3 id='legacy-display'>
349-
Legacy Display Values</h3>
367+
Elements with either of these values do not have <a>inner</a> or <a>outer display types</a>,
368+
because they don't generate any boxes at all.
350369

351-
CSS level 2 conflated the concepts of <a>inner</a> and <a>outer display types</a>,
352-
so that block-level and inline-level variants of the same layout mode were given separate names.
353-
Now that 'display' separates those,
354-
these legacy values can be mapped into the separate concepts they represent.
370+
<h3 id='legacy-display'>
371+
Precomposed Inline-level Display Values</h3>
355372

356-
The <<display-legacy>> keywords are defined as follows:
373+
CSS level 2 used a single-keyword syntax for 'display',
374+
requiring separate keywords for block-level and inline-level variants of the same layout mode.
375+
These <<display-legacy>> keywords map as follows:
357376

358377
<dl dfn-type=value dfn-for="display, <display-legacy>">
359378
<dt><dfn>inline-block</dfn>

0 commit comments

Comments
 (0)