Copyright © 2013 W3C® (MIT, ERCIM, Keio, Beihang), All Rights Reserved. W3C liability, trademark and document use rules apply.
CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc. 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.
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 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 www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css-overflow-3” in the subject, preferably like this: “[css-overflow-3] …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 css-overflow-3.
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].
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 | paged-x | paged-y | paged-x-controls | paged-y-controls | fragments |
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 | paged-x | paged-y | paged-x-controls | paged-y-controls | fragments |
Initial: | see individual properties |
Applies to: | block containers |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | see individual properties |
Animatable: | no |
Canonical order: | per grammar |
The values of these properties are:
The computed values of ‘overflow-x
’ and ‘overflow-y
’ are
determined from the cascaded values [CSS3CASCADE] based on the
following rules:
overflow-y
’ is the cascaded value and the
computed value for ‘overflow-x
’ is ‘hidden
’, or
overflow-x
’ is the cascaded value and the
computed value for ‘overflow-y
’ is ‘hidden
’.
visible
’, then
computed values are the cascaded values with ‘visible
’ changed to ‘hidden
’.
Are all 4 of the ‘paged-*
’
values really needed?
When the fragmenting values
are used, the overflow from the fragments themselves treats the
fragmenting value as ‘hidden
’. Is this the right
behavior? Give example.
[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?
There are discussions about how overflow, overflow-style, overflow-x and overflow-y should work and interact with each other. Until consensus on this topic is reached, it is not completely clear which of these should be used for paged-x | paged-y | paged-x-controls | paged-y-controls | fragments
Move material from [CSS21] and [CSS3BOX] here.
overflow:paginate or overflow:pages (or paged-x, paged-y, paged-x-controls, paged-y-controls as [CSS3GCPM] has?)
Ability to display N pages at once rather than just one page at once?
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). We
should probably switch away from ‘overflow-style
’, but that's not 100% clear.
This section introduces and defines the meaning of the new ‘fragments
’ value of the
‘overflow
’
property.
When the computed value of ‘overflow
’ 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 ‘overflow: fragments
’ to generate only one fragment box. However, if an element's
computed ‘overflow
’ 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 { overflow: 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 ‘overflow:
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
’ property cause breaks within this context.
We probably want ‘break: regions
’ 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.
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.
Should this apply to fragment overflow only, or also to paginated overflow? (If it applies, then stricter property restrictions would be needed for paginated overflow.)
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 { overflow: 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 ‘overflow
’ property does take effect; if a fragment box has a computed value of ‘overflow
’ other than
‘fragments
’ then that
fragment box is the last fragment. However, overriding ‘overflow
’ 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. Need to reword this to refer to the appropriate choice of
‘overflow-x
’ or ‘overflow-y
’, and then
point to rule about the handling of the other one of ‘overflow-x
’ or ‘overflow-y
’.
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 ‘overflow
’,
‘overflow-x
’,
and ‘overflow-y
’
only apply 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 { overflow: 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
propertyspecified 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. |
Should this apply to fragment overflow only, or also to paginated overflow, or even to pagination across pages?
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:
::first-letter
’ pseudo-element,
::nth-fragment()
’
pseudo-elements been removed, with a particular association between each
sequence of simple selectors and the element it matched, and
::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 { overflow: 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> |
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 |
Animatable: | as integer |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
Canonical order: | per grammar |
Breaks occur only as specified elsewhere.
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?
<!DOCTYPE HTML> <style> .article { overflow: 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, butthat 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). |
This specification should define useful behavior for all
values of ‘overflow
’ 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.
This module extends the ‘overflow
’ feature defined in [CSS21] section 11.1.1. It defines
additional overflow handling mechanisms that implementations must
implement as described in this module in order to conform to this module.
No properties in this module apply to the ::first-line
or
::first-letter
pseudo-elements.
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.
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 CSS Overflow Module Level 3 is defined for three conformance classes:
A style sheet is conformant to CSS Overflow Module 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 Overflow Module Level 3 if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by CSS Overflow Module 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 Overflow Module 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.
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 public-css-testsuite@w3.org mailing list.
[Change or remove the following CR exit criteria if the spec is not a module, but, e.g., a Note or a profile. This text was decided on 2008-06-04.]
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:
The specification will remain Candidate Recommendation for at least six months.
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.
Property | Values | Initial | Applies to | Inh. | Percentages | Media |
---|---|---|---|---|---|---|
max-lines | none | <integer> | none | fragment boxes | no | N/A | visual |
overflow | visible | hidden | scroll | auto | paged-x | paged-y | paged-x-controls | paged-y-controls | fragments | see individual properties | block containers | no | N/A | visual |
overflow-x | visible | hidden | scroll | auto | paged-x | paged-y | paged-x-controls | paged-y-controls | fragments | visible | block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT] | no | N/A | visual |
overflow-y | visible | hidden | scroll | auto | paged-x | paged-y | paged-x-controls | paged-y-controls | fragments | visible | block containers [CSS21], flex containers [CSS3-FLEXBOX], and grid containers [CSS3-GRID-LAYOUT] | no | N/A | visual |