CSS Region Styling Module Level 3

Unofficial Draft 7 August 2012

Issue Tracking:
Maintained in document (only editor's draft is current)
, Mozilla


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 containers, allowing the contents to flow across multiple regions of a page or to have different styles for different parts.

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 “css3-region-styling” in the subject, preferably like this: “[css3-region-styling] …summary of comment…

This document might in the future be produced by the CSS Working Group (part of the Style Activity).

This document might in the future be 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.

The following features are at risk: …

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 a region 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 region into which the content of an element must flow, this specification allows authors to specify multiple regions, 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. Paginated overflow

overflow:paginate or overflow:pages (or paged-x, paged-y, paged-x-controls, paged-y-controls as css3-gcpm has?)

Ability to display N pages at once rather than just one page at once?

3. Region overflow

This section introduces and defines the meaning of the new ‘regions’ (or ‘repeat’?) value of the ‘overflow’ property.

When the computed value of ‘overflow’ for an element is ‘regions’, and implementations would otherwise have created a box for the element, then implementations must create at least one box for that element. Each box created for the element is called a region box for that element. (If an element with ‘overflow: regions’ generates only one box, that box is a region box. However, if an element's computed ‘overflow’ is not ‘regions’, then its box is not a region box.) Every region box is a fragmentation container, and for each region box which ends with a fragmentation break, (which could happen because breakable content overflows in the block dimension or because of a forced break), there must be another region 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. (Breakable content might overflow in the box dimension either because of a specified size on the region box or because the region box is within a fragmentation context in which it is being broken. In other words, a single region box is never broken across columns or pages; the pieces that are in separate columns or pages are always distinct region boxes.)

We also want ‘::nth-region()’ pseudo-elements to be able to apply to the pieces of an element split within a fragmentation context. Should we require that authors who want to use ‘::nth-region()’ in this way specify ‘overflow:regions’ (even if they don't specify a constrained height), or should it work automatically for all elements even if they don't have ‘overflow: regions’?

<title>Breaking content into
  equal-sized cards</title>
  .in-cards {
    overflow: regions;

    width: 13em;
    height: 8em;

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

    font: medium/1.3 Times New
      Roman, Times, serif;
<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.
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.

3.1. Region styling

3.1.1. The ::nth-region() pseudo-element

The ::nth-region() pseudo-element is a pseudo-element that describes some of the region 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 region boxes generated by the element instead of siblings of the element.

If we go with a name for the ‘overflow’ value other than ‘overflow: regions’, then we should probably rename this pseudo-element, perhaps to ::nth-piece(), ::nth-part(), or ::nth-instance().

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

3.1.2. Styling of regions

Should this apply to region 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-region()’ pseudo-elements, the computed style for each region box is the computed style for the element for which the region box was created. However, the style for a region box is also influenced by rules whose selector's subject [SELECT] has an ‘::nth-region()’ pseudo-element, if the 1-based number of the region box matches that ‘::nth-region()’ pseudo-element and the selector (excluding the ‘::nth-region()’ pseudo-element) matches the element generating the regions.

  .bouncy-columns {
    overflow: regions;
    width: 6em;
    height: 10em;
    float: left;
    margin: 1em;
    font: medium/1.25 Times New
      Roman, Times, serif;
  .bouncy-columns::nth-region(1) {
    background: aqua; color: black;
    transform: rotate(-3deg);
  .bouncy-columns::nth-region(2) {
    background: yellow; color: black;
    transform: rotate(3deg);
<div class="bouncy-columns">
In this
example, the
text in the div
is broken into
a series of
columns. The
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
styling because
the author
didn't give it

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

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

Would it make more sense to forbid ‘display:none’? Or perhaps to forbid ‘display’, ‘position’, ‘float’, and similar (in addition to ‘overflow’)?

To match the model for other pseudo-elements where the pseudo-elements live inside their corresponding element, declarations in ‘::nth-region()’ 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-region()’ pseudo-elements do affect inheritance to content within the region box. In other words, the content within the region box must inherit from the region box's style (i.e., the pseudo-element style) rather than directly from the element. This means that elements split between region 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 regions should also apply to inheritance from regions.

  .article {
    overflow: regions;
  .article::nth-region(1) {
    font-size: 1.5em;
    margin-bottom: 1em;
    height: 4em;
  .article::nth-region(n+2) {
    /* 2 and up */
    margin-left: 5em;
    margin-right: 2em;
<div class="article">
  The <code>font-size</code> property...
The font-size property
specified on the region
is inherited into the
descendants of the region.
This means that inherited
properties can be used
reliably on a region, as in
this example.

3.1.3. Styling inside regions

Should this apply to region overflow only, or also to paginated overflow, or even to pagination across pages?

The ‘::nth-region()’ pseudo-element can also be used to style content inside of a region box. Unlike the ‘::first-line’ and ‘::first-letter’ pseudo-elements, the ‘::nth-region()’ 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-region()’ 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-region()’ 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-region()’ pseudo-element, the fragment lives within a region 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.
  .dark-columns {
    overflow: regions;
    width: 6em;
    height: 10em;
    float: left;
    margin-right: 1em;
    font: medium/1.25 Times New
      Roman, Times, serif;
  .dark-columns::nth-region(1) {
    background: aqua; color: black;
  .dark-columns::nth-region(1) :link {
    color: blue;
  .dark-columns::nth-region(1) :visited {
    color: purple;
  .dark-columns::nth-region(2) {
    background: navy; color: white;
  .dark-columns::nth-region(2) :link {
    color: aqua;
  .dark-columns::nth-region(2) :visited {
    color: fuchsia;
<div class="dark-columns">
In this
example, the
text flows
from one
region into
region. We
therefore want
different styles
for hyperlinks
in the different

3.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 region. However, since it may be difficult to predict the exact height occupied by those lines in order to restrict the first region to that height, this specification introduces a ‘max-lines’ property that forces a region 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: region boxes
Inherited: no
Percentages: N/A
Media: visual
Computed value: specified value
Animatable: as integer
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 regions overflow only, or also to pagination?

  .article {
    overflow: regions;
  .article::first-letter {
    font-size: 2em;
    line-height: 0.9;
  .article::nth-region(1) {
    font-size: 1.5em;
    max-lines: 3;
  .article::nth-region(n+2) {
    /* 2 and up */
    column-count: 2;
<div class="article">
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).

4. Conformance

4.1. Module interactions

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.

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

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

4.4. Conformance classes

Conformance to CSS Region Styling Module Level 3 is defined for three conformance classes:

style sheet
A CSS style sheet.
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 Region Styling 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 Region Styling 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 Region Styling 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 Region Styling 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.

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

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

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

4.8. CR exit criteria

[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:

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


Thanks especially to the feedback from Håkon Wium Lie, Florian Rivoal, Alan Stearns, and all the rest of the www-style community.


Normative references

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
Rossen Atanassov; Elika J. Etemad. CSS Fragmentation Module Level 3. 28 February 2012. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2012/WD-css3-break-20120228/
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. Internet RFC 2119. URL: http://www.ietf.org/rfc/rfc2119.txt
Tantek Çelik; et al. Selectors Level 3. 29 September 2011. W3C Recommendation. URL: http://www.w3.org/TR/2011/REC-css3-selectors-20110929/

Other references

Håkon Wium Lie; Bert Bos. Cascading Style Sheets (CSS1) Level 1 Specification. 11 April 2008. W3C Recommendation. URL: http://www.w3.org/TR/2008/REC-CSS1-20080411
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


Property index

Property Values Initial Applies to Inh. Percentages Media
max-lines none | <integer> none region boxes no N/A visual