W3C

CSS Intrinsic & Extrinsic Sizing Module Level 3

W3C Working Draft 27 September 2012

This version:
http://www.w3.org/TR/2012/WD-css3-sizing-20120927/
Latest version:
http://www.w3.org/TR/css3-sizing/
Editor's draft:
http://dev.w3.org/csswg/css3-sizing/
Issue Tracking:
W3C Bugzilla
Feedback:
www-style@w3.org with subject line “[css3-sizing] … message topic …
Editors:
Tab Atkins Jr., Google Inc.
Elika J. Etemad, Mozilla

Abstract

This module extends the CSS sizing properties with keywords that represent content-based "intrinsic" sizes and context-based "extrinsic" sizes, allowing CSS to more easily describe boxes that fit their content or fit into a particular layout context. 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 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/.

Publication as a 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 www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css3-sizing” in the subject, preferably like this: “[css3-sizing] …summary of comment…

This document was produced by the CSS Working Group (part of the Style Activity).

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 is the first public working draft of the css3-sizing module.

Table of contents

1. Introduction

This section is not normative.

CSS layout has several different concepts of automatic sizing that are used in various layout calculations. This section defines some more precise terminology to help connect the layout behaviors of this spec to the calculations used in other modules, and some new keywords for the ‘width’ and ‘height’ properties to allow authors to assign elements the dimensions resulting from these size calculations.

1.1. Module interactions

This module extends the ‘width’, ‘height’, ‘min-width’, ‘min-height’, ‘max-width’, ‘max-height’, and ‘column-width’ features defined in [CSS21] chapter 10 and in [CSS3COL]

1.2. 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 inherit keyword as their property value. For readability it has not been repeated explicitly.

2. Terminology

size
A one- or two-dimensional measurement: a measure and/or extent; alternatively a width and/or height.
definite size
A size that can be determined without measuring content; that is, a <length>, a size of the initial containing block, or a <percentage> that is resolved against a definite size.
indefinite size
A size that is not definite. An indefinite available size is essentially infinite.
available size
The space into which a box is laid out, typically either a measurement of its containing block or an infinite size. An available size can alternatively be either a min-content constraint or a max-content constraint.
fallback size
Some sizing algorithms do not work well with an infinite size. In these cases, the fallback size is used instead. Unless otherwise specified, this is the size of the initial containing block.
fill-available measure
Roughly, the measure a box would take if it filled its available measure. (See Extrinsic Size Determination.)

Note: This is called the available width in CSS2.1§10.3.5 and computed by the rules in CSS2.1§10.3.3.

max-content measure
Roughly, the narrowest measure a box could take while fitting around its contents if none of the soft wrap opportunities within the box were taken. (See Intrinsic Size Determination.)

Note: This is called the preferred width in CSS2.1§10.3.5 and the maximum cell width in CSS2.1§17.5.2.2.

min-content measure
The narrowest measure a box could take that doesn't lead to inline-dimension overflow that could be avoided by choosing a larger measure. Roughly, the measure that would fit around its contents if all soft wrap opportunities within the box were taken. (See Intrinsic Size Determination.)

Note: This is called the preferred minimum width in CSS2.1§10.3.5 and the minimum content width in CSS2.1§17.5.2.2.

fit-content measure
If the available measure is finite, equal to min(max-content, max(min-content, fill-available)). Otherwise, equal to the max-content measure.

Note: This is called the shrink-to-fit width in CSS2.1§10.3.5 and CSS Multi-column Layout § 3.4.

fill-available extent
Roughly, the extent a box would take if it filled its available extent. (See Intrinsic Size Determination.)
max-content extent
Roughly, the extent of the content after layout.
min-content extent
Equivalent to the max-content extent. Or should this be the minimum between allowed break points? It might make sense in multi-col contexts to have min-content and max-content extents be different, even if they are the same elsewhere.
fit-content extent
Analogous to the fit-content measure.
max-size contribution
The size that a box contributes to its containing block's max-content size.
min-size contribution
The size that a box contributes to its containing block's min-content size.
max-size constraint
A sizing constraint imposed by the box's containing block that causes it to produce its max-size contribution.
min-size constraint
A sizing constraint imposed by the box's containing block that causes it to produce its min-size contribution.

3. New Sizing Keywords

3.1. New Keywords for ‘width’ and ‘height

Properties: width’, ‘min-width’, ‘max-width’, ‘height’, ‘min-height’, ‘max-height
New Values: fill-available’ | ‘max-content’ | ‘min-content’ | ‘fit-content
Initial: as defined in [CSS21] and [CSS3-FLEXBOX]
Applies to: as defined in [CSS21]
Inherited: as defined in [CSS21]
Percentages: as defined in [CSS21]
Media: as defined in [CSS21]
Computed value: specified value if keyword specified, else as defined in [CSS21]

There are four types of automatically-determined sizes in CSS (which are represented in the width and height properties by the keywords defined above):

fill-available
Use the fill-available measure or fill-available extent, as appropriate to the writing mode.
max-content
Use the max-content measure or max-content extent, as appropriate to the writing mode.
min-content
Use the min-content measure or min-content extent, as appropriate to the writing mode.
fit-content
Use the fit-content measure or fit-content extent, as appropriate to the writing mode.
repudiate-floats
In the inline axis, use the larger of the min-content measure, and the fill-available measure minus the size of any non-descendant floats in the same formatting context. (This is similar to the behavior of a box that establishes a formatting context next to a float.) In the block axis, this is identical to ‘auto’.

Does this value work? Is it needed? Also: less stupid name?

Right now all of these except ‘fill-available’ mean the same thing for extents. This may or may not be ideal.

If the measure is ‘auto’, we could have min-content extent imply a max-content measure, and vice versa.

3.2. Containing Floats

Properties: min-width’, ‘min-height
New Value: contain-floats
Initial: as defined in [CSS21] and [CSS3-FLEXBOX]
Applies to: as defined in [CSS21]
Inherited: as defined in [CSS21]
Percentages: as defined in [CSS21]
Media: as defined in [CSS21]
Computed value: specified value if keyword specified, else as defined in [CSS21]
contain-floats
Equivalent to ‘min-content’ except that when applied to the extent of a block box it forces the inner extent to be large enough to contain the margin boxes of any floats that originate inside the block and that participate in the same block formatting context as the block's immediate contents.

3.3. Column Sizing Keywords

Property: column-width
New Values: min-content’ | ‘max-content’ | ‘fill-available’ | ‘fit-content
Initial: as defined in [CSS3COL]
Applies to: as defined in [CSS3COL]
Inherited: as defined in [CSS3COL]
Percentages: as defined in [CSS3COL]
Media: as defined in [CSS3COL]
Computed value: specified value if keyword specified, else as defined in [CSS3COL]

When used as values for column-width, the new keywords specify the optimal column width:

min-content
Specifies the optimal column width as the min-content measure of the multi-column element's contents.
max-content
Specifies the optimal column width as the max-content measure of the multi-column element's contents.
fill-available
Specifies the optimal column width as the fill-available measure of the multi-column element.
fit-content
Specifies the optimal column width as min(max-content, max(min-content, fill-available)).

4. Intrinsic Size Determination

Intrinsic sizing determines sizes based on the contents of an element, without regard for its context.

4.1. Intrinsic Sizes of Replaced Elements

For replaced elements, the min-content and max-content sizes are equivalent and correspond to the used size of the replaced element according to the ‘auto’ size calculation in the corresponding dimension. (See [CSS3-IMAGES].)

4.2. Intrinsic Sizes of Non-Replaced Inlines

The min-content measure of an inline box is the length of the largest unbreakable sequence of inline content. The min-measure contribution of an inline box is its min-content measure, plus any inline-axis margin, border, and padding adjacent to that sequence.

The max-content measure of an inline box is the length of the largest sequence of inline content on a single line when only forced line breaks are taken. The max-measure contribution of an inline box is its max-content measure, plus any inline-axis margin, border, and padding adjacent to that sequence.

The min-content extent, max-content extent, min-extent contribution, and max-content contribution of an inline box are the distance from the head edge of the first line box to the foot edge of the last line box on which the inline appears.

4.3. Intrinsic Sizes of Non-Replaced Blocks

The min-content measure of a block container box is the largest min-measure contribution of its in-flow or floated children.

The max-content measure of a block container box is the measure of the box after layout, if all children are sized under a max-size constraint.

If the computed measure of a block-level box is ‘min-content’, ‘max-content’, or a definite size, its min-measure contribution is that size plus any inline-axis margin, border, and padding. Otherwise, if the computed measure of the block is ‘fit-content’, ‘auto’, or ‘fill-available’, its min-measure contribution is its min-content measure plus any inline-axis margin, border, and padding.

If the computed measure of a block-level box is ‘min-content’, ‘max-content’, or a definite size, its max-measure contribution is that size plus any inline-axis margin, border, and padding. Otherwise, if the computed measure of the block is ‘fit-content’, ‘auto’, or ‘fill-available’, its max-measure contribution is its max-content measure plus any inline-axis margin, border, and padding.

The min-content extent and max-content extent of a block container box is the content extent as defined (for horizontal writing modes) in CSS2.1§10.6.3 and CSS2.1§17.5.3 for elements with ‘height: auto’, and analogously for vertical writing modes.

The min-extent contribution and max-extent contribution of a block-level box is the extent of the block after layout, plus any block-axis margin, border, and padding.

4.4. Intrinsic Sizes in Table Layout

???

4.5. Intrinsic Sizes in Multi-column Layout

Multi-column elements are different from most in that they grow sideways when their height is restricted. The ‘max-content’ value should be able to accommodate this somehow, in particular as this is how multi-column elements work in orthogonal flows. See also this explanation

5. Extrinsic Size Determination

Extrinsic sizing determines sizes based on the context of an element, without regard for its contents.

The inner fill-available measure of a box is the larger of…

…less the box's inline-axis margins, borders, and padding.

The fill-available extent of a box is defined analogously, but in the other dimension.

6. Conformance

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

6.2. Conformance classes

Conformance to CSS Intrinsic & Extrinsic Sizing Level 3 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 Intrinsic & Extrinsic Sizing Level 3 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 Intrinsic & Extrinsic Sizing Level 3 if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by CSS Intrinsic & Extrinsic Sizing Level 3 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 Intrinsic & Extrinsic Sizing Level 3 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.

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

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

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

6.6. CR exit criteria

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

Special thanks go to Aaron Gustafson, L. David Baron for their contributions to this module.

References

Normative references

[CSS21]
Bert Bos; et al. Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification. 7 June 2011. W3C Recommendation. URL: http://www.w3.org/TR/2011/REC-CSS2-20110607
[CSS3-FLEXBOX]
Tab Atkins Jr.; Elika J. Etemad; Alex Mogilevsky. CSS Flexible Box Layout Module. 12 June 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2012/WD-css3-flexbox-20120612/
[CSS3-IMAGES]
Elika J. Etemad; Tab Atkins Jr. CSS Image Values and Replaced Content Module Level 3. 17 April 2012. W3C Candidate Recommendation. (Work in progress.) URL: http://www.w3.org/TR/2012/CR-css3-images-20120417/
[CSS3COL]
Håkon Wium Lie. CSS Multi-column Layout Module. 12 April 2011. W3C Candidate Recommendation. (Work in progress.) URL: http://www.w3.org/TR/2011/CR-css3-multicol-20110412
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. Internet RFC 2119. URL: http://www.ietf.org/rfc/rfc2119.txt

Other references

[CSS3COLOR]
Tantek Çelik; Chris Lilley; L. David Baron. CSS Color Module Level 3. 7 June 2011. W3C Recommendation. URL: http://www.w3.org/TR/2011/REC-css3-color-20110607

Index

Property index

Property Values Initial Applies to Inh. Percentages Media
as defined in [CSS21] and [CSS3-FLEXBOX] as defined in [CSS21] as defined in [CSS21] as defined in [CSS21] as defined in [CSS21]
as defined in [CSS21] and [CSS3-FLEXBOX] as defined in [CSS21] as defined in [CSS21] as defined in [CSS21] as defined in [CSS21]
as defined in [CSS3COL] as defined in [CSS3COL] as defined in [CSS3COL] as defined in [CSS3COL] as defined in [CSS3COL]