CSS Overflow Module Level 3

Editor’s Draft,

This version:
http://dev.w3.org/csswg/css-overflow/
Latest version:
http://www.w3.org/TR/css-overflow-3/
Previous Versions:
http://www.w3.org/TR/2013/WD-css-overflow-3-20130418/
Feedback:
www-style@w3.org with subject line “[css-overflow] … message topic …” (archives)
Issue Tracking:
Inline In Spec
Editors:
L. David Baron (Mozilla)
(Invited Expert)
Change Log:
from 27 January 2015 to the present
from 28 March 2013 to 27 January 2015
from 31 July 2012 to 27 March 2013

Abstract

This module contains the features of CSS relating to new mechanisms of overflow handling in visual media (e.g., screen or paper). In interactive media, it describes features that allow the overflow from a fixed size container to be handled by pagination (displaying one page at a time). It also describes features, applying to all visual media, that allow the contents of an element to be spread across multiple fragments, allowing the contents to flow across multiple regions or to have different styles for different fragments.

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 a public copy of the editors’ draft. It is provided for discussion only and may change at any moment. Its publication here does not imply endorsement of its contents by W3C. Don’t cite this document other than as 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 “css-overflow” in the subject, preferably like this: “[css-overflow] …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 document is governed by the 1 August 2014 W3C Process Document.

Table of Contents

1. Introduction

In CSS Level 1 [CSS1], placing more content than would fit inside an element with a specified size was generally an authoring error. Doing so caused the content to extend outside the bounds of the element, which would likely cause that content to overlap with other elements.

CSS Level 2 [CSS21] introduced the overflow property, which allows authors to have overflow be handled by scrolling, which means it is no longer an authoring error. It also allows authors to specify that overflow is handled by clipping, which makes sense when the author’s intent is that the content not be shown.

However, scrolling is not the only way to present large amounts of content, and may even not be the optimal way. After all, the codex replaced the scroll as the common format for large written works because of its advantages.

This specification introduces a mechanism for Web pages to specify that an element of a page should handle overflow through pagination rather than through scrolling.

This specification also extends the concept of overflow in another direction. Instead of requiring that authors specify a single area into which the content of an element must flow, this specification allows authors to specify multiple fragments, each with their own dimensions and styles, so that the content of the element can flow from one to the next, using as many as needed to place the content without overflowing.

In both of these cases, implementations must break the content in the block-progression dimension. Implementations must do this is described in the CSS Fragmentation Module [CSS3-BREAK].

2. Types of overflow

CSS uses the term overflow to describe the contents of a box that extend outside that one of that box’s edges (i.e., its content edge, padding edge, border edge, or margin edge). The overflow might be described as the elements or features that cause this overflow, the non-rectangular region occupied by these features, or, more commonly, as the minimal rectangle that bounds that region. A box’s overflow is computed based on the boxes and styles of the box and of all its descendants whose containing block chain undefined term? includes the box.

In most cases, any of these types of overflow can be computed for any box from the bounds and properties of that box, and from the overflow (of that type) of each of its children. However, this is not always the case; for example, when transform-style: preserve-3d [CSS3-TRANSFORMS] is used on some of the children, their descendants with transform-style: preserve-3d must also be examined.

2.1. Ink overflow

The ink overflow of a box is the part of that box and its contents that creates a visual effect outside of the box’s border box.

Since some effects in CSS (for example, the blurs in text-shadow [CSS3TEXT] and box-shadow [CSS3BG]) do not define what visual extent they cover, the extent of the ink overflow is undefined.

Should we try to define it at all and just leave pieces undefined?

The ink overflow region is the non-rectangular region occupied by the ink overflow, and the ink overflow rectangle is the minimal rectangle whose axis is aligned to the box’s axes and contains the ink overflow region. Note that the ink overflow rectangle is a rectangle in the box’s coordinate system, but might be non-rectangular in other coordinate systems due to transforms [CSS3-TRANSFORMS].

2.2. Scrollable overflow

The scrollable overflow of a box is the set of things extending outside of that box’s padding edge for which a scrolling mechanism needs to be provided.

The following definition should be rewritten to use the concept of 3D rendering context [CSS3-TRANSFORMS] and related terms, particularly once those concepts stabilize following changes proposed in the CSS WG meeting on the morning of 2014-01-28.

Given the following definitions which belong in [CSS3-TRANSFORMS]:

3d-preserving child
A child box B of a containing block C is a 3d-preserving child if it has transform-style: preserve-3d and the user-agent is not required to flatten it based on the requirements in [CSS3-TRANSFORMS].
non-3d-preserving child
A child C of a box P is a non-3d-preserving-child if it is not a 3d-preserving child.
3d-preserving descendant
Box D is a 3d-preserving descendant of box A if A is an ancestor of D, and D and all of the boxes (if any) in the containing block chain from D to A are 3d-preserving child boxes.

The scrollable overflow of a box is the union of the following things, all adjusted for transforms undefined concept! into the box’s coordinate space:

I wrote this definition off the top of my head, so it can’t possibly be right. It’s missing tons of pieces!

The handling of preserve-3d subtrees here is probably wrong; the elements should probably count only towards the overflow of the element that flattens them.

The scrollable overflow region is the non-rectangular region occupied by the scrollable overflow, and the scrollable overflow rectangle is the minimal rectangle whose axis is aligned to the box’s axes and contains the scrollable overflow region. Note that the scrollable overflow rectangle is a rectangle in the box’s coordinate system, but might be non-rectangular in other coordinate systems due to transforms [CSS3-TRANSFORMS].

2.3. Border box overflow

This concept has been proposed for some uses, such as for determining what the outline property goes around, and as the basis of a coordinate system for specifying clips and masks, but it’s not clear if it’s needed.

The border-box overflow of a box is the union of the box’s border edge and the border edges of the box’s descendants.

If needed, define more formally, as for scrollable overflow above. (Maybe even share the definitions in an appropriate way!)

The border-box overflow region is the non-rectangular region occupied by the border-box overflow, and the border-box overflow rectangle is the minimal rectangle whose axis is aligned to the box’s axes and contains the border-box overflow region. Note that the border-box overflow rectangle is a rectangle in the box’s coordinate system, but might be non-rectangular in other coordinate systems due to transforms [CSS3-TRANSFORMS].

3. Overflow properties

The overflow-x property specifies the handling of overflow in the horizontal direction (i.e., overflow from the left and right sides of the box), and the overflow-y property specifies the handling of overflow in the vertical direction (i.e., overflow from the top and bottom sides of the box)

Name: overflow-x, overflow-y
Value: visible | hidden | scroll | auto
Initial: visible
Applies to: block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT]
Inherited: no
Percentages: N/A
Media: visual
Computed value: see below
Animatable: no
Canonical order: per grammar

The overflow property is a shorthand property that sets the specified values of both overflow-x and overflow-y to the value specified for overflow.

Name: overflow
Value: visible | hidden | scroll | auto
Initial: see individual properties
Applies to: block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT]
Inherited: no
Percentages: N/A
Media: visual
Computed value: see individual properties
Animatable: no
Canonical order: per grammar

The computed values of overflow-x and overflow-y are determined from the cascaded values [CSS3CASCADE] based on the following rules:

  1. If one cascaded values is visible and the other is not, then computed values are the cascaded values with visible changed to auto.
  2. Otherwise, the computed values are as specified.

The values of these properties are:

visible
There is no special handling of overflow, that is, it may be rendered outside the block container.
hidden
scroll
auto

Move material from [CSS21] and [CSS3BOX] here.

Explain which directions allow scrolling and which don’t, as a function of direction (including propagation of direction to the ICB).

[CSS3-MARQUEE] describes an overflow-style property, but it has not picked up implementation experience that the working group is aware of. Should this document treat overflow-style as a defunct proposal, or should this document describe the overflow-style property and attempt to revive it, despite that implementations have implemented overflow-x and overflow-y instead?

4. Fragmentation of overflow

The continue property gives authors the ability to request that content that does not fit inside an element be fragmented (in the sense of [CSS3-BREAK]), and provides alternatives for where the remaining content should continue.

Notably, this property explains traditional pagination, and extends it further.

Name: continue
Value: auto | overflow | paginate | fragments | discard
Initial: auto
Applies to: block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT]
Inherited: no
Percentages: N/A
Media: visual
Computed value: see below
Animatable: no
Canonical order: per grammar

The naming of this property and its values is preliminary. This was initially proposed as "fragmentation: auto | none | break | clone | page" in https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html, and there is not yet wide agreement as to which naming is better.

This property is meant to generalize and replace region-fragment. Once it is sufficiently stable in this specification, region-fragment should be removed from the regions specification in favor of this.

Note: continue: fragments replaces "overflow:fragments" from earlier versions of this specification, while continue: paginate replaces "overflow: paged-x | paged-y | paged-x-controls | paged-y-controls"

auto
auto may only occur as a computed value if the element is a CSS Region other than the last one in a region chain. Content that doesn’t fit is pushed to the next region of the chain.

In all other cases, auto computes to one of the other values.

overflow
Content that doesn’t fit overflows, according to the overflow property
discard
Content that doesn’t fit is discarded at a fragmentation break

Note: generalized from region-fragment: break; on the last region of a region chain

When the element isn’t a fragmentation container already, should this work by turning it directly into one, or by creating a fragment box inside it like fragments does?

paginate
Content that doesn’t fit paginates. This creates a paginated view inside the element similar to the way that 'overflow: scroll' creates a scrollable view.

See paginated overflow

Note: Print is effectively "continue: paginate" on the root.

fragments
content that doesn’t fit causes the element to copy itself and continue laying out.

See fragment overflow.

The computed value of the continue for a given element or pseudo element is determined as follow:

  1. If the specified value is auto
    1. On a CSS Region other than the last one in a region chain, the computed value is auto
    2. On a page the computed value is paginate
    3. On a fragment box the computed value is fragments
    4. Otherwise, the computed value is overflow
  2. If the specified value is framgents
    1. On a page the computed value is paginate
    2. Otherwise, the computed value is the specified value
  3. In all other cases, the computed value is the specified value

If we introduce a pseudo element that can select columns in a multicol, we would need to specify that auto computes to auto on it, or introduce a new value and have auto compute to that (but what would that value compute to on things that aren’t columns?).

Note: For background discussions leading to this property, see these threads: discussion of overflow, overflow-x, overflow-y and overflow-style and proposal for a fragmentation property

5. Paginated overflow

This section introduces and defines the meaning of the paginate value of the continue property.

Write this section

Pages should be possible to style with @page rules. How does that work for nested pages?

Should traditional pagination (e.g. when printing) be expressed through some magic in the computed value of auto, or by inserting this in the UA stylesheet:
@media (overflow-block: paged), (overflow-block: optional-paged) {
  :root {
    continue: paginate;
  }
}

Traditional pagination (e.g. when printing) assumes that :root is contained in the page box, rather than having the page box be a pseudo element child of :root. Can we work around that using something similar to fragment boxes? Or maybe by having a fragment box (reproducing :root) inside a page box inside :root?

How does the page box model work when it is a child of a regular css box?

The initial proposal in [CSS3GCPM] and implemantation from Opera used 4 values instead of paginate: "paged-x | paged-y | paged-x-controls | paged-y-controls". Should this property also include these values, or are they better handled as separate properties? (e.g.: "pagination-layout: auto | horizontal | vertical", "pagination-controls: auto | none")

Ability to display N pages at once rather than just one page at once? Could this be a value of "pagination-layout", such as: "pagination-layout: horizontal 2;"

Brad Kemper has proposed a model for combining pagination and fragment overflow, which also deals with displaying multiple pages. http://www.w3.org/mid/FF1704C5-D5C1-4D6F-A99D-0DD094036685@gmail.com

The current implementation of paginated overflow uses the overflow/overflow-x/overflow-y properties rather than the overflow-style property as proposed in the [CSS3GCPM] draft (which also matches the [CSS3-MARQUEE] proposal). or the continue property as described here.

6. Fragment overflow

This section introduces and defines the meaning of the fragments value of the continue property.

When the computed value of continue for an element is fragments, and implementations would otherwise have created a box for the element, then implementations must create a sequence of fragment boxes for that element. (It is possible for an element with continue: fragments to generate only one fragment box. However, if an element’s computed continue is not fragments, then its box is not a fragment box.) Every fragment box is a fragmentation container, and any overflow that would cause that fragmentation container to fragment causes another fragment box created as a next sibling of the previous one. Or is it as though it’s a next sibling of the element? Need to figure out exactly how this interacts with other box-level fixup. Additionally, if the fragment box is also a multi-column box (as defined in [CSS3COL] though it defines multi-column element) any content that would lead to the creation of overflow columns [CSS3COL] instead is flown into an additional fragment box. However, fragment boxes may themselves be broken (due to fragmentation in a fragmentation context outside of them, such as pages, columns, or other fragment boxes); such breaking leads to fragments of the same fragment box rather than multiple fragment boxes. (This matters because fragment boxes may be styled by their index; such breaking leads to multiple fragments of a fragment box with a single index. This design choice is so that breaking a fragment box across pages does not break the association of indices to particular pieces of content.) Should a forced break that breaks to an outer fragmentation context cause a new fragment of a single fragment box or a new fragment box? Should we find a term other than fragment box here to make this a little less confusing?

What if we want to be able to style the pieces of an element split within another type of fragmentation context? These rules prevent ever using ::nth-fragment() for that, despite that the name seems the most logical name for such a feature.

<!DOCTYPE HTML>
<title>Breaking content into
  equal-sized cards</title>
<style>
  .in-cards {
    continue: fragments;

    width: 13em;
    height: 8em;

    padding: 4px;
    border: medium solid blue;
    margin: 6px;

    font: medium/1.3 Times New
      Roman, Times, serif;
  }
</style>
<div class="in-cards">
  In this example, the text in the div
  is broken into a series of cards.
  These cards all have the same style.
  The presence of enough content to
  overflow one of the cards causes
  another one to be created.  The second
  card is created just like it’s the
  next sibling of the first.
</div>
In this example, the text in the
div is broken into a series of
cards. These cards all have the
same style. The presence of
enough content to overflow
one of the cards causes another
one to be created. The second
card is created just like it’s the
next sibling of the first.

We should specify that continue: fragments does not apply to at least some table parts, and perhaps other elements as well. We need to determine exactly which ones.

This specification needs to say which type of fragmentation context is created so that it’s clear which values of the break-* properties cause breaks within this context. We probably want break-*: region to apply.

This specification needs a processing model that will apply in cases where the layout containing the fragments has characteristics that use the intrinsic size of the fragments to change the amount of space available for them, such as [CSS3-GRID-LAYOUT]. There has already been some work on such a processing model in [CSS3-REGIONS], and the work done on a model there, and the editors of that specification, should inform what happens in this specification.

6.1. Fragment styling

6.1.1. The ::nth-fragment() pseudo-element

The ::nth-fragment() pseudo-element is a pseudo-element that describes some of the fragment boxes generated by an element. The argument to the pseudo-element takes the same syntax as the argument to the :nth-child() pseudo-class defined in [SELECT], and has the same meaning except that the number is relative to fragment boxes generated by the element instead of siblings of the element.

Selectors that allow addressing fragments by counting from the end rather than the start are intentionally not provided. Such selectors would interfere with determining the number of fragments.

Depending on future discussions, this ::nth-fragment(an+b) syntax may be replaced with the new ::fragment:nth(an+b) syntax.

6.1.2. Styling of fragments

Should this apply to continue:fragments only, or also to continue:paginate? (If it applies, then stricter property restrictions would be needed for continue:paginate.)

In the absence of rules with ::nth-fragment() pseudo-elements, the computed style for each fragment box is the computed style for the element for which the fragment box was created. However, the style for a fragment box is also influenced by rules whose selector’s subject [SELECT] has an ::nth-fragment() pseudo-element, if the 1-based number of the fragment box matches that ::nth-fragment() pseudo-element and the selector (excluding the ::nth-fragment() pseudo-element) matches the element generating the fragments.

When determining the style of the fragment box, these rules that match the fragment pseudo-element cascade together with the rules that match the element, with the fragment pseudo-element adding the specificity of a pseudo-class to the specificity calculation. Does this need to be specified in the cascading module as well?

<!DOCTYPE HTML>
<style>
  .bouncy-columns {
    continue: fragments;
    width: 6em;
    height: 10em;
    float: left;
    margin: 1em;
    font: medium/1.25 Times New
      Roman, Times, serif;
  }
  .bouncy-columns::nth-fragment(1) {
    background: aqua; color: black;
    transform: rotate(-3deg);
  }
  .bouncy-columns::nth-fragment(2) {
    background: yellow; color: black;
    transform: rotate(3deg);
  }
</style>
<div class="bouncy-columns">
  ...
</div>
In this
example, the
text in the div
is broken into
a series of
columns. The
author
probably
intended the
text to fill two
columns. But
if it happens to
fill three
columns, the
third column is
still created. It
just doesn’t
have any
fragment-specific
styling because
the author
didn’t give it
any.

Styling an ::nth-fragment() pseudo-element with the continue property does take effect; if a fragment box has a computed value of continue other than fragments then that fragment box is the last fragment. However, overriding continue on the first fragment does not cause the fragment box not to exist; whether there are fragment boxes at all is determined by the computed value of overflow for the element.

Styling an ::nth-fragment() pseudo-element with the content property has no effect; the computed value of content for the fragment box remains the same as the computed value of content for the element.

Specifying display: none for a fragment box causes the fragment box with that index not to be generated. However, in terms of the indices used for matching ::nth-fragment() pseudo-elements of later fragment boxes, it still counts as though it was generated. However, since it is not generated, it does not contain any content.

Specifying other values of display, position, or float is permitted, but is not allowed to change the computed value of display-inside. (Since continue only applies to block containers, flex containers, and grid containers the computed value of display-inside is always block, flex, or grid. Need to specify exactly how this works, but it depends on having display-inside and display-outside specified.

To match the model for other pseudo-elements where the pseudo-elements live inside their corresponding element, declarations in ::nth-fragment() pseudo-elements override declarations in rules without the pseudo-element. The relative priority within such declarations is determined by normal cascading order (see [CSS21]).

Styles specified on ::nth-fragment() pseudo-elements do affect inheritance to content within the fragment box. In other words, the content within the fragment box must inherit from the fragment box’s style (i.e., the pseudo-element style) rather than directly from the element. This means that elements split between fragment boxes may have different styles for different parts of the element.

This inheritance rule allows specifying styles indirectly (by using explicit inherit or using default inheritance on properties that don’t apply to ::first-letter) that can’t be specified directly (based on the rules in the next section). This is a problem. The restrictions that apply to styling inside fragments should also apply to inheritance from fragments.

<!DOCTYPE HTML>
<style>
  .article {
    continue: fragments;
  }
  .article::nth-fragment(1) {
    font-size: 1.5em;
    margin-bottom: 1em;
    height: 4em;
  }
  .article::nth-fragment(2) {
    margin-left: 5em;
    margin-right: 2em;
  }
</style>
<div class="article">
  The <code>font-size</code> property...
</div>
The font-size property
specified on the fragment
is inherited into the
descendants of the fragment.
This means that inherited
properties can be used
reliably on a fragment, as in
this example.

6.1.3. Styling inside fragments

Should this apply to continue:fragments only, or also to continue:paginate?

The ::nth-fragment() pseudo-element can also be used to style content inside of a fragment box. Unlike the ::first-line and ::first-letter pseudo-elements, the ::nth-fragment() pseudo-element can be applied to parts of the selector other than the subject: in particular, it can match ancestors of the subject. However, the only CSS properties applied by rules with such selectors are those that apply to the ::first-letter pseudo-element.

To be more precise, when a rule’s selector has ::nth-fragment() pseudo-elements attached to parts of the selector other than the subject, the declarations in that rule apply to a fragment (or pseudo-element thereof) when:

  1. the declarations are for properties that apply to the ::first-letter pseudo-element,
  2. the declarations would apply to that fragment (or pseudo-element thereof) had those ::nth-fragment() pseudo-elements been removed, with a particular association between each sequence of simple selectors and the element it matched, and
  3. for each removed ::nth-fragment() pseudo-element, the fragment lives within a fragment box of the element associated in that association with the selector that the pseudo-element was attached to, and whose index matches the pseudo-element.
<!DOCTYPE HTML>
<style>
  .dark-columns {
    continue: fragments;
    width: 6em;
    height: 10em;
    float: left;
    margin-right: 1em;
    font: medium/1.25 Times New
      Roman, Times, serif;
  }
  .dark-columns::nth-fragment(1) {
    background: aqua; color: black;
  }
  .dark-columns::nth-fragment(1) :link {
    color: blue;
  }
  .dark-columns::nth-fragment(1) :visited {
    color: purple;
  }
  .dark-columns::nth-fragment(2) {
    background: navy; color: white;
  }
  .dark-columns::nth-fragment(2) :link {
    color: aqua;
  }
  .dark-columns::nth-fragment(2) :visited {
    color: fuchsia;
  }
</style>
<div class="dark-columns">
  ...
</div>
In this
example, the
text flows
from one
light-colored
fragment into
another
dark-colored
fragment. We
therefore want
different styles
for hyperlinks
in the different
fragments.

6.2. The max-lines property

Authors may wish to style the opening lines of an element with different styles by putting those opening lines in a separate fragment. However, since it may be difficult to predict the exact height occupied by those lines in order to restrict the first fragment to that height, this specification introduces a max-lines property that forces a fragment to break after a specified number of lines. This forces a break after the given number of lines contained within the element or its descendants, as long as those lines are in the same block formatting context.

Name: max-lines
Value: none | <integer>
Initial: none
Applies to: fragment boxes
Inherited: no
Percentages: N/A
Media: visual
Computed value: specified value
Animatable: as integer
Canonical order: per grammar
none

Breaks occur only as specified elsewhere.

<integer>

In addition to any breaks specified elsewhere, a break is forced before any line that would exceed the given number of lines being placed inside the element (excluding lines that are in a different block formatting context from the block formatting context to which an unstyled child of the element would belong).

If there are multiple boundaries between this line and the previous, where exactly (in terms of element boundaries) is the break forced?

Only positive integers are accepted. Zero or negative integers are a parse error.

Should this apply to fragment overflow only, or also to pagination? Given what we’re doing with the continue property, it should actually apply to any fragmentainer.

having max-lines do nothing on regular elements is not ideal. When applied to non fragmentainers, it should probably cause continue to compute to discard so that you only need to reach for one property rather than 2 to get that effect.

<!DOCTYPE HTML>
<style>
  .article {
    continue: fragments;
  }
  .article::first-letter {
    font-size: 2em;
    line-height: 0.9;
  }
  .article::nth-fragment(1) {
    font-size: 1.5em;
    max-lines: 3;
  }
  .article::nth-fragment(2) {
    column-count: 2;
  }
</style>
<div class="article">
  ...
</div>
The max-lines property allows
authors to use a larger font for the first
few lines of an article. Without the
max-lines property, authors
might have to use the
height property instead, but
that would leave a slight gap
if the author miscalculated
how much height a given
number of lines would
occupy (which might be
particularly hard if the author
didn’t know what text would
be filling the space, exactly
what font would be used, or
exactly which platform’s font
rendering would be used to
display the font).

7. Overflow in static media

This specification should define useful behavior for all values of overflow and continue in static media (such as print). Current implementation behavior is quite poor and produces unexpected results when authors have not considered what will happen when the content they produce for interactive media is printed.

Acknowledgments

Thanks especially to the feedback from Rossen Atanassov, Bert Bos, Tantek Çelik, John Daggett, fantasai, Daniel Glazman, Vincent Hardy, Håkon Wium Lie, Peter Linss, Robert O’Callahan, Florian Rivoal, Alan Stearns, Steve Zilles, and all the rest of the www-style community.

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.

Advisements are normative sections styled to evoke special attention and are set apart from other normative text with <strong class="advisement">, like this: UAs MUST provide an accessible alternative.

Conformance classes

Conformance to this specification 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 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.

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.

Index

Terms defined by this specification

Terms defined by reference

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. 18 September 2012. W3C Candidate Recommendation. (Work in progress.) URL: http://www.w3.org/TR/2012/CR-css3-flexbox-20120918/
[CSS3-GRID-LAYOUT]
Tab Atkins Jr.; Elika J. Etemad; Rossen Atanassov. CSS Grid Layout. 2 April 2013. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2013/WD-css3-grid-layout-20130402/
[CSS3-TRANSFORMS]
Simon Fraser; et al. CSS Transforms. 11 September 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2012/WD-css3-transforms-20120911/
[CSS3CASCADE]
Håkon Wium Lie; Elika J. Etemad; Tab Atkins Jr.. CSS Cascading and Inheritance Level 3. 3 October 2013. W3C Candidate Recommendation. (Work in progress.) URL: http://www.w3.org/TR/2013/CR-css-cascade-3-20131003/
[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
[SELECT]
Tantek Çelik; et al. Selectors Level 3. 29 September 2011. W3C Recommendation. URL: http://www.w3.org/TR/2011/REC-css3-selectors-20110929/
[CSS-BACKGROUNDS-3]
CSS Backgrounds and Borders Module Level 3 URL: http://www.w3.org/TR/css3-background/
[CSS-BREAK-3]
CSS Fragmentation Module Level 3 URL: http://www.w3.org/TR/css3-break/
[CSS-CASCADE-3]
Håkon Wium Lie; Elika Etemad; Tab Atkins Jr.. CSS Cascading and Inheritance Level 3. 3 October 2013. CR. URL: http://www.w3.org/TR/css-cascade-3/
[CSS-CONTENT-3]
CSS Generated Content Module Level 3 URL: http://dev.w3.org/csswg/css-content-3/
[CSS-DISPLAY-3]
Tab Atkins Jr.; Elika Etemad. CSS Display Module Level 3. 11 September 2014. WD. URL: http://www.w3.org/TR/css-display-3/
[CSS-MULTICOL-1]
CSS Multi-column Layout Module Level 1 URL: http://www.w3.org/TR/css3-multicol/
[CSS-POSITION-3]
CSS Positioned Layout Module Level 3 URL: http://www.w3.org/TR/css3-positioning/
[CSS-PSEUDO-4]
Daniel Glazman; Elika Etemad; Alan Stearns. CSS Pseudo-Elements Module Level 4. 15 January 2015. WD. URL: http://www.w3.org/TR/css-pseudo-4/
[CSS-REGIONS-1]
Rossen Atanassov; Alan Stearns. CSS Regions Module Level 1. 9 October 2014. WD. URL: http://www.w3.org/TR/css-regions-1/
[CSS-TEXT-DECOR-3]
Elika Etemad; Koji Ishii. CSS Text Decoration Module Level 3. 1 August 2013. CR. URL: http://www.w3.org/TR/css-text-decor-3/
[CSS-TRANSFORMS-1]
Simon Fraser; et al. CSS Transforms Module Level 1. 26 November 2013. WD. URL: http://www.w3.org/TR/css-transforms-1/
[CSS-UI-3]
CSS Basic User Interface Module Level 3 URL: http://www.w3.org/TR/css3-ui/
[CSS-VALUES-3]
CSS Values and Units Module Level 3 URL: http://www.w3.org/TR/css3-values/
[CSS-WRITING-MODES-3]
Elika Etemad; Koji Ishii. CSS Writing Modes Level 3. 20 March 2014. CR. URL: http://www.w3.org/TR/css-writing-modes-3/
[CSS3-BREAK]
Rossen Atanassov; Elika Etemad. CSS Fragmentation Module Level 3. 29 January 2015. WD. URL: http://www.w3.org/TR/css3-break/
[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119

Informative References

[CSS1]
Håkon Wium Lie; Bert Bos. Cascading Style Sheets (CSS1) Level 1 Specification. 11 April 2008. REC. URL: http://www.w3.org/TR/CSS1/
[CSS3-REGIONS]
Vincent Hardy; Rossen Atanassov; Alan Stearns. CSS Regions Module Level 1. 28 May 2013. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2013/WD-css3-regions-20130528/
[CSS3BG]
Bert Bos; Elika J. Etemad; Brad Kemper. CSS Backgrounds and Borders Module Level 3. 24 July 2012. W3C Candidate Recommendation. (Work in progress.) URL: http://www.w3.org/TR/2012/CR-css3-background-20120724/
[CSS3BOX]
Bert Bos. CSS basic box model. 9 August 2007. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2007/WD-css3-box-20070809
[CSS3GCPM]
Håkon Wium Lie. CSS Generated Content for Paged Media Module. 29 November 2011. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2011/WD-css3-gcpm-20111129/
[CSS3TEXT]
Elika J. Etemad; Koji Ishii. CSS Text Module Level 3. 13 November 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2012/WD-css3-text-20121113/
[CSS3-MARQUEE]
Bert Bos. CSS Marquee Module Level 3. 14 October 2014. NOTE. URL: http://www.w3.org/TR/css3-marquee

Property Index

Name Value Initial Applies to Inh. %ages Media Animatable Canonical order Computed value
overflow-x visible | hidden | scroll | auto visible block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT] no N/A visual no per grammar see below
overflow-y visible | hidden | scroll | auto visible block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT] no N/A visual no per grammar see below
overflow visible | hidden | scroll | auto see individual properties block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT] no N/A visual no per grammar see individual properties
continue auto | overflow | paginate | fragments | discard auto block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT] no N/A visual no per grammar see below
max-lines none | <integer> none fragment boxes no N/A visual as integer per grammar specified value

Issues Index

undefined term?
Should we try to define it at all and just leave pieces undefined?
The following definition should be rewritten to use the concept of 3D rendering context [CSS3-TRANSFORMS] and related terms, particularly once those concepts stabilize following changes proposed in the CSS WG meeting on the morning of 2014-01-28.
which belong in [CSS3-TRANSFORMS]
undefined concept!
undefined term!
MORE HERE!
I wrote this definition off the top of my head, so it can’t possibly be right. It’s missing tons of pieces!
The handling of preserve-3d subtrees here is probably wrong; the elements should probably count only towards the overflow of the element that flattens them.
This concept has been proposed for some uses, such as for determining what the outline property goes around, and as the basis of a coordinate system for specifying clips and masks, but it’s not clear if it’s needed.
If needed, define more formally, as for scrollable overflow above. (Maybe even share the definitions in an appropriate way!)
Move material from [CSS21] and [CSS3BOX] here.
Explain which directions allow scrolling and which don’t, as a function of direction (including propagation of direction to the ICB).
[CSS3-MARQUEE] describes an overflow-style property, but it has not picked up implementation experience that the working group is aware of. Should this document treat overflow-style as a defunct proposal, or should this document describe the overflow-style property and attempt to revive it, despite that implementations have implemented overflow-x and overflow-y instead?
The naming of this property and its values is preliminary. This was initially proposed as "fragmentation: auto | none | break | clone | page" in https://lists.w3.org/Archives/Public/www-style/2015Jan/0357.html, and there is not yet wide agreement as to which naming is better.
This property is meant to generalize and replace region-fragment. Once it is sufficiently stable in this specification, region-fragment should be removed from the regions specification in favor of this.
When the element isn’t a fragmentation container already, should this work by turning it directly into one, or by creating a fragment box inside it like fragments does?
If we introduce a pseudo element that can select columns in a multicol, we would need to specify that auto computes to auto on it, or introduce a new value and have auto compute to that (but what would that value compute to on things that aren’t columns?).
Write this section
Pages should be possible to style with @page rules. How does that work for nested pages?
Should traditional pagination (e.g. when printing) be expressed through some magic in the computed value of auto, or by inserting this in the UA stylesheet:
@media (overflow-block: paged), (overflow-block: optional-paged) {
  :root {
    continue: paginate;
  }
}
Traditional pagination (e.g. when printing) assumes that :root is contained in the page box, rather than having the page box be a pseudo element child of :root. Can we work around that using something similar to fragment boxes? Or maybe by having a fragment box (reproducing :root) inside a page box inside :root?
How does the page box model work when it is a child of a regular css box?
The initial proposal in [CSS3GCPM] and implemantation from Opera used 4 values instead of paginate: "paged-x | paged-y | paged-x-controls | paged-y-controls". Should this property also include these values, or are they better handled as separate properties? (e.g.: "pagination-layout: auto | horizontal | vertical", "pagination-controls: auto | none")
Ability to display N pages at once rather than just one page at once? Could this be a value of "pagination-layout", such as: "pagination-layout: horizontal 2;"
Brad Kemper has proposed a model for combining pagination and fragment overflow, which also deals with displaying multiple pages. http://www.w3.org/mid/FF1704C5-D5C1-4D6F-A99D-0DD094036685@gmail.com
The current implementation of paginated overflow uses the overflow/overflow-x/overflow-y properties rather than the overflow-style property as proposed in the [CSS3GCPM] draft (which also matches the [CSS3-MARQUEE] proposal). or the continue property as described here.
Or is it as though it’s a next sibling of the element? Need to figure out exactly how this interacts with other box-level fixup.
though it defines multi-column element
Should a forced break that breaks to an outer fragmentation context cause a new fragment of a single fragment box or a new fragment box?
Should we find a term other than fragment box here to make this a little less confusing?
What if we want to be able to style the pieces of an element split within another type of fragmentation context? These rules prevent ever using ::nth-fragment() for that, despite that the name seems the most logical name for such a feature.
We should specify that continue: fragments does not apply to at least some table parts, and perhaps other elements as well. We need to determine exactly which ones.
This specification needs to say which type of fragmentation context is created so that it’s clear which values of the break-* properties cause breaks within this context. We probably want break-*: region to apply.
This specification needs a processing model that will apply in cases where the layout containing the fragments has characteristics that use the intrinsic size of the fragments to change the amount of space available for them, such as [CSS3-GRID-LAYOUT]. There has already been some work on such a processing model in [CSS3-REGIONS], and the work done on a model there, and the editors of that specification, should inform what happens in this specification.
Depending on future discussions, this ::nth-fragment(an+b) syntax may be replaced with the new ::fragment:nth(an+b) syntax.
Should this apply to continue:fragments only, or also to continue:paginate? (If it applies, then stricter property restrictions would be needed for continue:paginate.)
Does this need to be specified in the cascading module as well?
Need to specify exactly how this works, but it depends on having display-inside and display-outside specified.
This inheritance rule allows specifying styles indirectly (by using explicit inherit or using default inheritance on properties that don’t apply to ::first-letter) that can’t be specified directly (based on the rules in the next section). This is a problem. The restrictions that apply to styling inside fragments should also apply to inheritance from fragments.
Should this apply to continue:fragments only, or also to continue:paginate?
If there are multiple boundaries between this line and the previous, where exactly (in terms of element boundaries) is the break forced?
Should this apply to fragment overflow only, or also to pagination? Given what we’re doing with the continue property, it should actually apply to any fragmentainer.
having max-lines do nothing on regular elements is not ideal. When applied to non fragmentainers, it should probably cause continue to compute to discard so that you only need to reach for one property rather than 2 to get that effect.
This specification should define useful behavior for all values of overflow and continue in static media (such as print). Current implementation behavior is quite poor and produces unexpected results when authors have not considered what will happen when the content they produce for interactive media is printed.