CSS Display Module Level 3

[LONGSTATUS] [DATE]

This version:
http://www.w3.org/TR/[YEAR]/ED-cssN-FIXME-[CDATE]/
Latest version:
http://www.w3.org/TR/[SHORTNAME]/
Editor's draft:
http://dev.w3.org/csswg/[SHORTNAME]/
Previous version:
http://www.w3.org/PreviousVersionURI
Issue Tracking:
http://www.w3.org/Style/CSS/Tracker/products/FIXME
Feedback:
www-style@w3.org with subject line “[css-display] … message topic …” (archives)
Editors:
(Google, Inc.),

Abstract

This module contains the features of CSS relating to the 'display' property. CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc.

Status of this document

This is currently a personal draft, not yet approved by the CSSWG to be an Editor's Draft. (Ignore the branding on the side and heading, which are artifacts of the spec generation process.)

The following features are at risk: …

Table of contents

Introduction

This section is not normative.

Provide background, motivation, etc.

Module interactions

Explain, normatively, how this module affects the definition of CSS.

This module replaces and extends the SUMMARIZE HERE features defined in [[!CSS21]] sections W.X and Y.Z.

None of the properties in this module apply to the ::first-line or ::first-letter pseudo-elements.

Values

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: for example [[CSS3COLOR]], when combined with this module, expands the definition of the <color> value type as used in this specification.

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 Properties

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.

Setting the layout mode: the 'display-inside' property

Name: display-inside
Value: auto | block | table | flex | grid
Initial: auto
Applies To: all elements
Inherited: no
Percentages: N/A
Computed Value: a keyword
auto
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 ''block''.
block
The element lays out its contents using block layout. [[!CSS21]]
table
The element lays out its contents using table layout. [[!CSS21]]
flex
The element lays out its contents using flex layout. [[!CSS3-FLEXBOX]]
grid
The element lays out its contents using grid layout. [[!CSS3-GRID]]

Interacting with the layout mode: the 'display-outside' property

Name: display-outside
Value: block-level | inline-level | 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
block-level
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]]
inline-level
The element is inline-level, and participates in an inline formatting context. [[!CSS21]]
table-row-group, table-header-group, table-footer-group, table-row, table-cell, table-column-group, table-column, table-caption
The element is an internal table element, and participates in a table layout context. [[!CSS21]]

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?

Controlling box generation: the 'display-box' property

Name: display-box
Value: normal | none | contents
Initial: normal
Applies To: all elements
Inherited: no
Percentages: N/A
Computed Value: as specified
normal
The element generates boxes as normal, per its other 'display-*' properties.
none
The element generates no boxes at all.
contents
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.

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?

Additional stuff: the 'display-extras' property

Name: display-extras
Value: none | [ list-item ]
Initial: none
Applies To: all elements
Inherited: no
Percentages: N/A
Computed Value: as specified
list-item
The element generates a ::marker pseudo-element and is considered a list item.

The 'display' shorthand property

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 | none | [ <'display-inside'> || <'display-outside'> || <'display-box'> || <'display-extras'> ]
Initial: see individual properties
Applies To: all elements
Inherited: no
Percentages: 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).

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.

inline
Expands identically to ''inline-level auto''.
block
Expands identically to ''block-level block''.
list-item
Expands identically to ''block-level block list-item''.
inline-list-item
Expands identically to ''inline-level block list-item''.
inline-block
Expands identically to ''inline-level block''.
table
Expands identically to ''block-level table''.
inline-table
Expands identically to ''inline-level table''.
table-caption
Expands identically to ''table-caption block''.
table-cell
Expands identically to ''table-cell block''.
flex
Expands identically to ''block-level flex''.
inline-flex
Expands identically to ''inline-level flex''.
grid
Expands identically to ''block-level grid''.
inline-grid
Expands identically to ''inline-level grid''.
none
Expands identically to ''inline-level auto none''.

Conformance

Document conventions

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 classes

Conformance to CSS TEMPLATE Module is defined for three conformance classes:

style sheet
A CSS style sheet.
renderer
A UA that interprets the semantics of a style sheet and renders documents that use them.
authoring tool
A UA that writes a style sheet.

A style sheet is conformant to CSS TEMPLATE Module 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 CSS TEMPLATE Module if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by CSS TEMPLATE Module 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 CSS TEMPLATE Module 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.

Partial implementations

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.

Experimental implementations

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.

Non-experimental implementations

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 public-css-testsuite@w3.org mailing list.

CR exit criteria

Remove this section unless/until the module is in CR.

For this specification to be advanced to Proposed Recommendation, there must be at least two independent, interoperable implementations of each feature. Each feature may be implemented by a different set of products, there is no requirement that all features be implemented by a single product. For the purposes of this criterion, we define the following terms:

independent
each implementation must be developed by a different party and cannot share, reuse, or derive from code used by another qualifying implementation. Sections of code that have no bearing on the implementation of this specification are exempt from this requirement.
interoperable
passing the respective test case(s) in the official CSS test suite, or, if the implementation is not a Web browser, an equivalent test. Every relevant test in the test suite should have an equivalent test created if such a user agent (UA) is to be used to claim interoperability. In addition if such a UA is to be used to claim interoperability, then there must one or more additional UAs which can also pass those equivalent tests in the same way for the purpose of interoperability. The equivalent tests must be made publicly available for the purposes of peer review.
implementation
a user agent which:
  1. implements the specification.
  2. is available to the general public. The implementation may be a shipping product or other publicly available version (i.e., beta version, preview release, or “nightly build”). Non-shipping product releases must have implemented the feature(s) for a period of at least one month in order to demonstrate stability.
  3. is not experimental (i.e., a version specifically designed to pass the test suite and is not intended for normal usage going forward).

The specification will remain Candidate Recommendation for at least six months.

Acknowledgments

[acknowledgments]

References

Normative references

Other references

Index

Property index