This module contains the features of CSS relating to the display property and other box-generation details. CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This document is a First Public Working Draft.
Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
The (archived) public mailing list email@example.com (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-display” in the subject, preferably like this: “[css-display] …summary of comment…”
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This section is not normative.
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 before 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".
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
This specification follows the CSS property definition conventions 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 CSS-wide keywords as their property value. For readability it has not been repeated explicitly.
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.
|Value:||auto | block | table | flex | grid|
|Applies to:||all elements|
|Computed value:||a keyword|
|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|
|Applies to:||all elements|
|Computed value:||as specified|
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.
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?)
Is fantasai’s proposal for a run-in model sane enough to include in this spec?
|Value:||none | list-item|
|Applies to:||all elements|
|Computed value:||as specified|
::markerpseudo-element and is considered a list item.
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?
|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|
|Media:||see individual properties|
|Computed value:||see individual properties|
|Animatable:||see individual properties|
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.
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.
|Value:||normal | none | contents|
|Applies to:||all elements|
|Computed value:||see prose|
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 none, the computed value of display-box is none. Otherwise, the computed value is the specified value.
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.?
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?
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.
Conformance requirements are expressed with a combination of descriptive assertions and RFC 2119 terminology. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119. However, for readability, these words do not appear in all uppercase letters in this specification.
All of the text of this specification is normative except sections explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words "for
example" or are set apart from the normative text with
class="example", like this:
This is an example of an informative example.
Informative notes begin with the word "Note" and are set apart from the
normative text with
class="note", like this:
Note, this is an informative note.
Conformance to this specification is defined for three conformance classes:
A style sheet is conformant to this specification if all of its statements that use syntax defined in this module are valid according to the generic CSS grammar and the individual grammars of each feature defined in this module.
A renderer is conformant to this specification if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by this specification by parsing them correctly and rendering the document accordingly. However, the inability of a UA to correctly render a document due to limitations of the device does not make the UA non-conformant. (For example, a UA is not required to render color on a monochrome monitor.)
An authoring tool is conformant to this specification if it writes style sheets that are syntactically correct according to the generic CSS grammar and the individual grammars of each feature in this module, and meet all other conformance requirements of style sheets as described in this module.
So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid (and ignore as appropriate) any at-rules, properties, property values, keywords, and other syntactic constructs for which they have no usable level of support. In particular, user agents must not selectively ignore unsupported component values and honor supported values in a single multi-value property declaration: if any value is considered invalid (as unsupported values must be), CSS requires that the entire declaration be ignored.
To avoid clashes with future CSS features, the CSS2.1 specification reserves a prefixed syntax for proprietary and experimental extensions to CSS.
Prior to a specification reaching the Candidate Recommendation stage in the W3C process, all implementations of a CSS feature are considered experimental. The CSS Working Group recommends that implementations use a vendor-prefixed syntax for such features, including those in W3C Working Drafts. This avoids incompatibilities with future changes in the draft.
Once a specification reaches the Candidate Recommendation stage, non-experimental implementations are possible, and implementors should release an unprefixed implementation of any CR-level feature they can demonstrate to be correctly implemented according to spec.
To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the testcases used for that implementation report) to the W3C before releasing an unprefixed implementation of any CSS features. Testcases submitted to W3C are subject to review and correction by the CSS Working Group.
Further information on submitting testcases and implementation reports can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/. Questions should be directed to the firstname.lastname@example.org mailing list.
|Name||Value||Initial||Applies to||Inh.||%ages||Media||Animatable||Computed value|
|display-inside||auto | block | table | flex | grid||auto||all elements||no||n/a||all||a keyword|
|display-outside||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||inline-level||all elements||no||n/a||all||as specified|
|display-extras||none | list-item||none||all elements||no||n/a||all||as specified|
|display||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’> ]||see individual properties||see individual properties||see individual properties||see individual properties||see individual properties||see individual properties|
|display-box||normal | none | contents||normal||all elements||no||n/a||all||see prose|