W3C

CSS Regions Module Level 3

Editor's Draft 6 February 2012

This version:
http://www.w3.org/csswg/css3-regions
Latest version:
http://www.w3.org/TR/css3-regions/
Previous version:
http://www.w3.org/TR/2011/WD-css3-regions-20111129/
Issues:
Bugzilla Bugs for CSS regions
Editors:
Vincent Hardy, Adobe Systems, Inc.,
Alex Mogilevsky, Microsoft,

Abstract

The CSS regions module allows content to flow across multiple areas called regions. The regions are not necessarily contiguous in the document order. The CSS regions module provides an advanced content flow mechanism, which can be combined with positioning schemes as defined by other CSS modules such as the Multi-Column Module [CSS3COL] or the Grid Layout Module [CSS3-GRID-LAYOUT] to position the regions where content flows.

Status of this document

Note This document uses an experimental style sheet. We welcome your feedback on the styles at site-comments@w3.org.

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-regions” in the subject, preferably like this: “[css3-regions] …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 draft is related to the drafts about Multi-column Layout [CSS3COL], Grid Layout [CSS3GRID], Flexible Box Layout [CSS3-FLEXBOX], and Template Layout [CSS3LAYOUT].

Table of contents

1. Introduction

This section is non-normative.

Bug-15159

Add code samples to the CSS regions use cases page

Capturing the complex layouts of a typical magazine, newspaper, or textbook requires capabilities beyond those available in existing CSS modules. This is the purpose of the CSS regions module.

The CSS regions module can be seen as an extension of the concept of multi-column elements. With CSS Multi-column layout [CSS3COL], columns share the same dimensions and define column boxes organized in rows. Content flows from one column to the next.

The multi-column model is an example of flowing content from one area to another, where the areas are the multi-column element's column boxes and the flow is made of the multi-column element's children.

Bug-15733

Should the region specification define a mechanism to create blocks that can be regions with CSS syntax?

However, for more complex layouts, content needs to flow from one area of the page to the next without limitation of the areas' sizes and positions. These arbitrary areas are the target of specific content flows. In this document these areas are called regions, and the content flows are called named flows. Regions are based on the rectangular geometry of the CSS box model. Elements in a named flow are taken out of the normal visual formatting and rendered in a chain of regions.

1.1. Named flows and regions

Consider the layout illustrated in figure 1.

multiple chained regions which should receive content from a flow

Layout requiring sophisticated content flow

Bug-15131

Add layout to initial example

The designer's intent is to position an image in region ‘A’ and to flow an article's text from region ‘1’, to region ‘2’, ‘3’ and ‘4’.

The following code snippet shows the content to flow between the regions 1, 2, 3 and 4.

<div id="article">
  <h1>Introduction</h1>
  <p>This is an example ...</p>
    
  <h1>More Details</h1>
  <p>This illustrates ...</p>
  <p>Then, the example ...</p>
  <p>Finally, this ...</p>
</div>
        

And the following snippet shows an example using grid cells to define the region areas:

<style>
    #page {
      width: 800px;
      height: 600px;
      grid-template: "aaa.e"
                     "....e"
                     "bbb.e"
                     "....e"
                     "c.d.e";
      grid-rows: 52% 4% 20% 4% 20%;
      grid-columns: 30% 5% 30% 5% 30%;
    }
    #regionA { grid-cell: a; }
    #region1 { grid-cell: b; }
    #region2 { grid-cell: c; }
    #region3 { grid-cell: d; }
    #region4 { grid-cell: e; }
</style>

<div id="page">
    <div id="region1"></div>        
    <div id="region2"></div>        
    <div id="region3"></div>        
    <div id="region4"></div>
</div>
    

Any of the CSS layout facilities can be used to create, position and size regions as needed.

Using a grid layout (see [CSS3-GRID-LAYOUT] is just an example. The example could use a flexible box layout as well, see [CSS3-FLEXBOX].

The CSS regions specification does not define a layout mechanism and is meant to integrate with existing and future CSS layout facilities.

However, there is no existing mechanism to associate the content with the regions so that content flows as intended. Figure 2 shows an example of the intended visual rendering of the content.

Sample rendering showing a single thread of text flowing through a chain of regions

Sample rendering for desired layout

The CSS regions module is independent of the layout of regions and the mechanism used to create them. For simplicity, our example uses elements as regions as shown in the previous code snippet.

While the example uses elements as regions (since [CSS3-GRID-LAYOUT] requires elements to create grid items) it is important to note that this is not required for regions. Regions can be pseudo-elements, such as ‘::before’ and ‘::after’. The only requirement for an element or pseudo-element to become a region is that it needs to be subject to CSS styling to receive the ‘flow-from’ property.

The following code example illustrates how the content of the article element becomes a flow and how the areas ‘region1’, ‘region2’, ‘region3’ and ‘region4’ become regions that consume the ‘article_flow’ content.

<style>

#article {
    flow-into: article_flow;
}

#region1, #region2, #region3, #region4 {
    flow-from: article_flow;
}
</style>

The ‘article_flow’ value on the ‘flow-into’ property directs the ‘#article’ element to the ‘article_flow’ named flow. Setting the elements' ‘flow-from’ property to ‘article_flow’ on elements makes them regions and associates these regions with the named flow: the flow is ‘poured’ into the desired regions.

1.2. Regions styling

Region styling allows content to be styled depending on the region it flows into. It is a form of context-based styling, similar to Media Queries [MEDIAQ] which enable or disable selectors depending on the rendering context. With region styling, additional selectors may apply depending on the region into which content flows.

In our example, the designer wants to make text flowing into region 1 larger, bold and dark blue. In addition, <h1> headers should be crimson.

This design can be expressed with region styling as shown below.

<style>
/*
 * Default article styling.
 */
#article {
    color:#777;
    text-align: justify;
}

#article h1 {
    border-left: 1px solid #777;
    padding-left: 2ex;
    display: run-in;
}

/*
 * Additional styling to apply to content when it falls into 
 * region1
 */
@region #region1 {
    #article {
        font-weight: bold;
        color: #0C3D5F;
        font-size: larger;
    }

    #article h1 {
        color: crimson;
        border: none;
        padding: 0px;
    }
}


/*
 * Style that would apply to region1's normal content but
 * will not apply to its named flow content.
 */
#region1 p {
    color: red;
}

</style>

The ‘@region’ rule for region 1 limits its selectors to content flowing into region 1. The following figure shows how the rendering changes if we do not increase the font size nor make it bold for content flowing into region 1. As more content can be fitted, more content is subject to the contextual selectors, resulting in more dark blue text into region 1.

Illustrate how changing region styling affects the flow of content.

Different rendering with a different region styling

Finally, note how the ‘red’ color specified for <p> elements under #region1 does not apply to content that flows into the region. This specified style does not apply to the named flow content because the <p> elements in the ‘article’ named flow are not descendants of the #region1 element and, consequently, the "#region1 p" selector does not apply to these elements.

2. CSS regions concepts

2.1. Regions

Bug-15186

Is a mechanism to auto-generate regions necessary in order to support reusable style sheets?

Bug-15187

Explain how regions and pages interact. How can regions be placed onto certain pages, and how can they be positiond wrt. pages.

A region is an element that generates a block container box and has an associated named flow (see the ‘flow-from’ property).

2.2. Named flow

A named flow is the ordered sequence of elements associated with a flow with a given identifier. Elements in a named flow are ordered according to the document order.

Elements are placed into a named flow with the ‘flow-into’ property. The elements in a named flow are laid out in the chain of regions that are associated with this named flow. Regions are organized in to a region chain according to the document order.

Content from a named flow is broken up between regions according to the regions flow breaking rules.

2.3. Regions flow breaking rules

Breaking a named flow across multiple regions is similar to breaking a document's content across multiple pages (see [CSS3PAGE]) or a multi-column element's content across column boxes (see [CSS3COL]). One difference is that page boxes are generated based on the available content whereas regions are a set of recipient boxes for the named flow content whose dynamic generation is not in the scope of this specification.

Regions are organized in to a region chain.

Each region in turn consumes content from its associated named flow. The named flow content is positioned in the current region until a natural or forced region break occurs, at which point the current region becomes the next one in the region chain. If there are no more regions in the region chain and there is still content in the flow, the positioning of the remaining content is controlled by the ‘region-overflow’ property on the last region in the chain.

3. Relation to document events

The CSS regions module does not alter the normal processing of events in the document tree. In particular, if an event occurs on an element that is part of a named flow, the event's bubble and capture phases happen following the document tree order.

4. Properties and rules

This section is normative.

4.1. The ‘flow-into’ property

Bug-15811

Creating a named flow from external resource

The ‘flow-into’ property can place an element into a named flow. Elements that belong to the same flow are laid out in the regions associated with that flow.

Name: flow-into
Value: <ident> | none | inherit
Initial: none
Applies to: any element
Inherited: no
Percentages: N/A
Media: visual
Computed value: as specified
none
The element is not moved to a named flow and normal CSS processing takes place.
<ident>
The element is taken out of its parent's flow and placed into the flow with the name ‘<ident>’. The element is said to have a specified flow. The values ‘none’, ‘inherit’, ‘default’, ‘auto’ and ‘initial’ are invalid flow names.

A named flow needs to be associated with one or more regions for its elements to be visually formatted. If no region is associated with a given named flow, the elements in the named flow are not rendered: they do not generate boxes and are not displayed.

The children of an element with a specified flow may themselves have a specified flow.

If an element has the same specified flow as one of its ancestors, it becomes a sibling of it's ancestor for the purpose of layout in the regions laying out content from that flow.

The ‘flow-into’ property does not affect the CSS cascade and inheritance for the elements on which it is specified. The ‘flow-into’ property affects the visual formatting of elements placed into a named flow and of regions laying out content from a named flow.

Bug-15858

Should first region be ICB for flow content?

Bug-15870

Describe how containing blocks are used for element fragments

The edges of the first region in a region chain associated with a named flow establish the rectangle that is the containing block used for absolutely positioned elements in the name named flow which do not have an ancestor with a ‘position’ of ‘absolute’, ‘relative’ or ‘fixed’ (see [CSS21]). That first region rectangle is used as the containing block instead of the initial containing block.

The first region defines the writing mode for the entire flow. The writing mode on subsequent regions is ignored.

Elements in a named flow are sequenced in document order.

Note

The ‘flow-into’ property moves an element into the flow and the interplay with selectors should be considered carefully.

For example,

table {flow-into: table-content}

will move all tables in the ‘table-content’ named flow. However, the

table > * {flow-into: table-content} ...

selector will move all immediate children of all table elements into the ‘table-content’ named flow (which may be useful as it will usually result, if the immediate children are rows, in merging rows of multiple tables), but the

table * {flow-into: table-content}

selector will move all descendants of table elements into the ‘table-content’ named flow, transforming the element tree into a flat list in order of opening tags (which is probably not intentional). This will make all the descendants of table elements siblings in the named flow. Having the descendants become siblings in the named flow results in a different processing (see the CSS 2.1‘s anonymous table objects). This note illustrates how authors must exercise caution when choosing a particular selector for setting the ’flow-into' property to avoid unintended results.

The ‘flow-into’ property does not apply to the ::first-line and ::first-letter pseudo-elements.

The effect of ‘flow-into’ on generated content such as ::marker, ::before and ::after is undefined. This may change depending on implementation feedback.

4.2. The ‘flow-from’ property

The ‘flow-from’ property makes an element a region and associates it with a named flow.

Bug-15191

Should we allow multi-column elements to be regions?

Name: flow-from
Value: <ident> | none | inherit
Initial: none
Applies to: Elements that generate a block container box.
This might be expanded in future versions of the specification to allow other types of containers to receive flow content.
Inherited: no
Percentages: N/A
Media: visual
Computed value: as specified
none
The element is not a region.
<ident>
If the ‘content’ property computes to something else than ‘normal’, the element does not become a region. If the ‘content’ property computes to ‘normal’, then the element becomes a region and is ordered in a region chain according to its document order. The content from the flow with the <ident> name will be broken into segments and visually formatted in the principal boxes of the regions in the region chain. If there is no flow with name <ident>, then the element does not format any content visually.
Likewise, if the element is part of the flow with name <ident>, then the element does not format any content visually.

Note A region's document children are not visually formatted unless they are directed to a named flow referenced by one or more regions.

Note

An element becomes a region when its ‘flow-from’ property is set to a valid <ident> value, even if there is no content contributing to the referenced flow. For example:

<style>
  .article{
    flow-into: thread;
  }
  .region{
    flow-from: thread;
  }
</style>
<html>
  <body>
    <div class=region>div content</div>
  </body>
</html>
        
There is no element matching the .article selector and therefore no content in the thread flow. However, the element matching the .region selector is still associated with that empty named flow and, consequently, its children are not formatted visually.
Bug-15189

Should regions be non-breakable?

Bug-15824

Should regions not create a new stacking context?

Bug-15827

Specify behavior of stacking contexts that are split between regions

Regions create a new stacking context. Regions establish a new block formatting Context.

Note

With regions, an element may be split across multiple regions and these regions may overlap (for example if they are absolutely positioned). So fragments of the same element can overlap each other. Since each element has a single z-index, it would be required to find another mechanism to decide in which order the  fragments are rendered. Since each region creates a new stacking context, it is clear that each region is rendered separately and their rendering order follows the regular CSS rendering model.

Floats or other exclusions (see [CSS3-EXCLUSIONS]) potentially impact the content laid out in regions, just as for non-regions.

4.2.1. Auto width on regions

Bug-15741

Regions intrinsic size

A computed value of ‘auto’ for a region's ‘width’ property becomes a used value calculated based on the region's ::before and ::after generated content only.

4.2.2. Auto height on regions

A computed value of ‘auto’ for a region's ‘height’ property becomes a used value calculated based on the region's ::before and ::after generated content only.

4.3. Region flow break properties: ‘break-before’, ‘break-after’, ‘break-inside

User agents laying out content in multiple regions must determine where content breaks occur. The problem of breaking content into segments fitting in regions is similar to breaking content into pages or columns.

Each break ends layout in the current region and causes remaining pieces of content from the named flow to be visually formatted in the following region in the region chain, if there is one.

The following extends the ‘break-before’, ‘break-after’ and ‘break-inside’ properties from the [CSS3COL] specification to account for regions. The additional values are described below.

Name: break-before
Value: auto | always | avoid | left | right | page | column | region | avoid-page | avoid-column | avoid-region
Initial: auto
Applies to: block-level elements
Inherited: no
Percentages: N/A
Media: paged
Computed value: specified value
Name: break-after
Value: auto | always | avoid | left | right | page | column | region | avoid-page | avoid-column | avoid-region
Initial: auto
Applies to: block-level elements
Inherited: no
Percentages: N/A
Media: paged
Computed value: specified value
Name: break-inside
Value: auto | avoid | avoid-page | avoid-column | avoid-region
Initial: auto
Applies to: block-level elements
Inherited: no
Percentages: N/A
Media: paged
Computed value: specified value

These properties describe page, column and region break behavior before/after/inside the generated box. These values are normatively defined in [CSS3COL]:

This specification adds the following new values:

region
Always force a region break before (after) the generated box.
avoid-region
Avoid a region break before (after, inside) the generated box.

The behavior of region breaks with regards to regions is identical to the behavior of page breaks with regards to pages, as defined in the [CSS21].

4.4. The region-overflow property

Bug-15878

region-overflow:nobreak

Name: region-overflow
Value: auto | break
Initial: auto
Applies to: region elements
Inherited: no
Percentages: N/A
Media: paged
Computed value: specified value
Bug-15832

Should we have region-overflow:nobreak and have region-overflow apply to all regions, not just the last?

The ‘region-overflow’ property controls the behavior of the last region associated with a named flow.

auto
Content flows as it would in a regular content element. If the content exceeds the container box, it is subject to the overflow property's computed value on the region element. Region breaks must be ignored on the last region.
break

If the content fits within the region element, then this property has no effect. If the content does not fit within the region element, the content breaks as if flow was going to continue in a subsequent region. See the breaking rules section. A forced region break takes precedence over a natural break point.

Flow content that follows the last break in the last region, if any is not rendered.

The ‘region-overflow’ property does not influence the size of the region it applies to.

The following code sample illustrates the usage of the ‘region-overflow’ property.

<style>
#article {
    flow-into: "article";
}

#region_1, #region_2 {
    flow-from: article;
    region-overflow: break; /* or none */
    overflow: visible; /* or hidden */
}

</style>

<div id="article">...</div>

<div id="region_1"></div>
<div id="region_2"></div>
        
flow-into: "article"region_1 and region_2 region-overflow: auto
overflow:visible
regions receiving the flow content result if region-overflow is set to 'break' regions receiving the flow content
region-overflow: breakregion-overflow: auto
overflow:hidden
result if region-overflow is set to 'break' regions receiving the flow content

Different values for the region-overflow property

Note

The ‘overflow’ property is honored on a region: if region content overflows, such as the borders of elements on the last line, the ‘overflow’ property controls the visibility of the overflowing content. See the ‘overflow’ property definition ([CSS21]).

4.5. The @region rule

Bug-15116

Add CSS OM Interface for @region style rules

An ‘@region’ rule contains style declarations specific to particular regions.

@region <selector> {
    ... CSS styling rules ...
}         
    

The ‘@region’ rule consists of the keyword ‘@region’ followed by a selector and a block of style rules. The ‘@region’ rule and the selector constitute the region's ‘flow segment’ selector. The region's flow segment selector specifies which range of elements in the flow are subject to the style rules in the following block: it applies to the range (see [DOM-LEVEL-2-TRAVERSAL-RANGE]) from the region's flow that flows in the selected region(s).

Bug-15713

Model for styling element fragments

Elements that are fully or partially in the ‘flow segment’ may match any of the selectors found in the style rule. However, the style rules only apply to the portion of the element that falls into the corresponding region.

Only a limited list of properties can be set in a region style rule:

Bug-15190

List of region style properties

  1. font properties
  2. color property
  3. background property
  4. word-spacing
  5. letter-spacing
  6. text-decoration
  7. text-transform
  8. line-height
  9. border properties
  10. rounded corner properties
  11. border images properties
  12. margin properties
  13. padding properties
  14. text-shadow’ property
  15. box-shadow’ property
  16. box-decoration-break’ property
  17. width’ property

In the following example, the named flow ‘article_flow’ flows through ‘region_1’ and ‘region_2’.

<style>
    #div_1 {
        flow-into: article_flow;
    }
    
    #region1, #region2 {
        flow-from: article_flow;
    }

    /* region style "RSA" */
    @region #region1, #region2 {
        div {...}
        p {...}
    }
    
    /* region style "RSB" */
    @region #region1 {
        p {...}
    }
        
</style>

<div id="div_1">
    <p id="p_1">...</p>
    <p id="p_2">...</p>
</div>

<div id="region1"></div>
<div id="region2"></div>
        
Illustration showing how a named flow content fits into regions to illustrate the @region styling.

The region style ‘RSA’ applies to flow content that is laid out in either ‘region_1’ or ‘region_2’.

The first rule set ‘div {...}’ applies to all <div> elements that fit partially or fully into ‘region_1’ or ‘region_2’. div_1 is split between ‘region_1’ and ‘region_2’ and gets the style from this style rule.

The second rule set ‘p {...}’ applies to all <p> elements that fit into ‘region_1’ or ‘region_2’. In our example, both p_1 and p_2 are selected.

The region style ‘RSB’ applies to flow content that fits in ‘region_1’.

The first rule set ‘p {...}’ matches p_1 and p_2 because these paragraphs flow into ‘region_1’. Only the segment of p_2 that flows into region_1 is styled with this rule.

Bug-15734

@region and specificity

The specificity of the selectors in a ‘@region’ rule is calculated as defined in the CSS Selectors module (see [SELECT]). In other words, the ‘@region’ rule adds an extra condition to the selector's matching, but does not change the selector's specificity. This is the same behavior as selectors appearing in ‘@media’ rules declaration blocks (see [MEDIAQ]), where the rule does not influence the selectors' specificity.

Consequently, selectors that match a given element (as describe above), participate in the CSS Cascading order as defined in [CSS21].

Region styling does not apply to nested regions. For example, if a region ‘A’ receives content from a flow that contains region ‘B’, the content that flows into ‘B’ does not receive the region styling specified for region ‘A’.

5. Pseudo-elements

Bug-15188

add functionality for having textual description like "continued here" or "continued on page x" to regions.

It can be useful to visually mark the content to highlight that a content thread is flowing from region to region. For example, a marker such as continues on page 3 clearly indicates, at the end of a region, that there is more content in the flow which can be found on ‘page 3’ (in this example, the notion of page is application specific).

The ‘::before’ and ‘::after’ pseudo-elements (see [SELECT]) let content authors mark the beginning and end of a region with such markers.

5.1. Processing model

The ‘::before’ content is laid out in the region prior to any other content coming from the flow. Note that it is possible to set the ‘::before’ pseudo-element's ‘display’ property to ‘run-in’ to align it with the content's inline boxes.

The ‘::after’ content is laid out in the region after laying out the flow content. Then, flow content is removed from the region to accommodate for the ‘::after’ content. Accommodating means that the ‘::after’ content is laid out without overflowing the region. If there is still not enough room to accommodate for the ‘::after’ content after removing all flow content, then the ‘::after’ content overflows. The ‘display’ property of the ‘::after’ content can be set to ‘run-in’ to align with the region's content's inline boxes. In that case, the ‘::after’ content becomes the last inline box of the previous element in the flow that has some visual rendering in the region and can accommodate for the ‘::after’ box.

6. CSSOM view and CSS regions

Bug-15679

elementFromPoint and CSS regions

Since content may flow into multiple regions, authors need a way to determine if there are enough regions to flow all the content from a named flow. This is especially important considering that the size of regions may change depending on the display context. For example, flowing the same content on a mobile phone with a small screen may require more regions than on a large desktop display.

Bug-15010

Need to add a CSSRegionRule to Region OM

Another example where creating more regions might be needed: if the user may change the font size of text flowing through regions, new regions may be needed to accommodate for the additional space required to fit the larger text or some regions may need to be removed for smaller text.

Note

Since an element may be split into multiple regions, invoking getClientRects on it must return the list of rectangles for the element in all the regions it is part of.

6.1. The NamedFlow interface

Bug-14948

What should getFlowByName return if there is no flow with the given name?

Supplemental methods on the Document interface provide access to named flows.

[Supplemental] interface Document {
  NamedFlow getFlowByName(DOMString name);
  NamedFlowCollection getNamedFlows();
};               

The getNamedFlows method on the Document interface returns the list of all the named flows in the document.

The getFlowByName method on the Document interface provides access to the document's named flow instances.

Bug-15828

Should add a ‘name’ property on NamedFlow and should have a Document method to get all existing NamedFlow instances.

The NamedFlowCollection interface provides a list of current NamedFlow instances in the document. The collection is live and methods operate on the underlying data, not a snapshot of the data.

interface NamedFlowCollection {
    readonly attribute unsigned long length;
    caller getter NamedFlow item (in unsigned long index);
}
    

The length attribute returns the number of items in the collection.

The item(index) method returns the item at index index in the collection or null if index is out of range.

The NamedFlow interface offers a representation of the named flow.

Bug-15879

getRegionsByContentNode and contentNodes: change naming?

interface NamedFlow {
  readonly attribute DOMString name;
  readonly attribute boolean overflow;
  readonly attribute NodeList contentNodes;
  NodeList getRegionsByContentNode(Node node);
};

The name attribute returns the name of the NamedFlow instance.

The overflow attribute returns true if the named flow does not fully fit in the associated regions. Otherwise, it returns false. A NamedFlow object is live.

The contentNodes attribute returns an ordered collection of nodes that constitute the named flow. Note that this collection is live: every time it is queried it must return the same object, and the object is always up to date.

The getRegionsByContentNode() method gets a collection of regions that contain at least part of the target content node. The returned NodeList is live: every time the method is called with the same node argument, it must return the same object, and the object is always up to date.This can be used to navigate by bookmark in paginated view: the method returns regions containing the bookmarked element, which are then passed to pagination UI to show desired region or page.

With the NamedFlow interface, authors can easily check if all content has been fitted into existing regions. If it has, the overflow property would be false.

6.2. Extension to the Element interface

When an region is an actual element, it is convenient to easily find out if content fully fits into the region or not. The supplemental interface on Element provides that functionality.

[Supplemental] interface Element {
    readonly attribute DOMString regionOverflow;
    getter Range[] getRegionFlowRanges();
};               
    

The regionOverflow attribute returns one of the following values:

overflow
the region is the last one in the region chain and not able to fit the remaining content from the named flow. Note that the region's overflow property value can be used to control the visibility of the overflowing content.
fit
the region element's content fits into the region's content box. It does not overflow. If the region is the last one in the region chain, it means that the content fits without overflowing. If the region is not the last one in the region chain, that means the named flow content is further fitted in subsequent regions. In particular, in this last case, that means the region may have received no content from the named flow (for example if the region is too small to accommodate any content).
empty
the region element has no content and is empty. All content from the named flow was fitted in regions with a lower document order.
undefined
The element is not a region.

Note that if there is no content in the named flow, all regions associated with that named flow should have their ‘overflow’ attribute return ‘empty’. If there is content in the flow but that content does not generate any box for visual formatting, the ‘overflow’ attribute on the first region in the region chain associated with the flow will return ‘fit’.

The getRegionFlowRanges method returns an array of Range instances corresponding to the content from the region flow that is positioned in the region.

If an element is not a region, the getRegionFlowRanges method throws a DOMException with the INVALID_ACCESS_ERR error code.

Note The Element interface extension is only available to regions that are document elements and not to regions that are pseudo-elements.

6.3. Region flow layout events

Bug-15009

Should we have additional events for CSS Regions?

Region Event Targets dispatch regionLayoutUpdate events when there is a possible layout change of their named flow segment.

Type regionLayoutUpdate
Interface UIEvent
Sync / Async Async
Bubbles Yes
Target Element
Cancelable Yes
Default action none
Context info
  • Event.target: region whose layout may have changed

7. Relation to other specifications

This specification is related to other specifications as described in the references section. In addition, it is related to the following specifications:

  1. CSS Exclusions Module [CSS3-EXCLUSIONS]. This module defines a generic way to define arbitrarily shaped exclusions into which content can flow or around which content can flow. This can be seen as an extension to the way CSS floats provide rectangular areas into which content flows and around which content flows. In advanced layout designs, it is expected that the CSS Exclusions module will be commonly combined with the CSS regions module.
  2. CSS Line Grid Module [CSS3-LINE-GRID]. This module defines a concept of line grid to align the position of lines in different elements. The line grid functionality is related and needed for aligning content flowing in separate regions.

8. Use Cases

Use cases are described on this page.

9. Conformance

10. Changes

10.1. Changes from November 29th 2011 version

10.2. Changes from June 09th 2011 version

Acknowledgments

The editors are grateful to the CSS working group for their feedback and help with the genesis of this specification.

In addition, the editors would like to thank the following individuals for their contributions, either during the conception of CSS regions or during its development and specification review process:

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

Other references

[CSS3-EXCLUSIONS]
Vincent Hardy; Rossen Atanassov. CSS Exclusions and Shapes Module Level 3. 13 December 2011. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2011/WD-css3-exclusions-20111213/
[CSS3-FLEXBOX]
Tab Atkins Jr.; Alex Mogilevsky; L. David Baron. CSS Flexible Box Layout Module. 29 November 2011. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2011/WD-css3-flexbox-20111129/
[CSS3-GRID-LAYOUT]
Alex Mogilevsky; et al. Grid Layout. 7 April 2011. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2011/WD-css3-grid-layout-20110407
[CSS3-LINE-GRID]
Koji Ishii. CSS Line Grid Module. Proposal for a CSS module. (Retrieved 26 October 2011) URL: http://dev.w3.org/csswg/css-line-grid/
[CSS3GRID]
Alex Mogilevsky; Markus Mielke. CSS Grid Positioning Module Level 3. 5 September 2007. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2007/WD-css3-grid-20070905
[CSS3LAYOUT]
Bert Bos; César Acebal. CSS Template Layout Module. 29 April 2010. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2010/WD-css3-layout-20100429
[CSS3PAGE]
Håkon Wium Lie; Melinda Grant. CSS3 Module: Paged Media. 10 October 2006. W3C Working Draft. (Work in progress.) URL: http://www.w3.org/TR/2006/WD-css3-page-20061010
[DOM-LEVEL-2-TRAVERSAL-RANGE]
Joe Kesselman; et al. Document Object Model (DOM) Level 2 Traversal and Range Specification. 13 November 2000. W3C Recommendation. URL: http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113
[MEDIAQ]
Håkon Wium Lie; et al. Media Queries. 27 July 2010. W3C Candidate Recommendation. (Work in progress.) URL: http://www.w3.org/TR/2010/CR-css3-mediaqueries-20100727/

Index

Property index

Bug-{{bug_id}}

{{short_desc}}

11. Issue manager