[css3-break] …message topic…
"
Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
This module describes the fragmentation model that partitions a flow into pages. It builds on the Page model module and introduces and defines the fragmentation model. It adds functionality for pagination, breaking variable fragment size and orientation, widows and orphans.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
The (archived) public mailing list www-style@w3.org (see instructions) is preferred for discussion of this specification. When sending e-mail, please put the text “css3-break” in the subject, preferably like this: “[css3-break] …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.
Changes since the previous draft are listed in the Changes section.
This section is not normative.
In paged media (e.g., paper, transparencies, photo album pages, pages displayed on computer screens as printed output simulations), as opposed to continuous media, the content of the document is split into one or more discrete display surfaces. In order to avoid awkward breaks (such as halfway through a line of text), the layout engine must be able to shift around content that would fall across the page break. This process is called pagination.
In CSS, in addition to paged media, certain layout features such as regions [CSS3-REGIONS] and multi-column layout [CSS3COL] create a similarly fragmented environment. The generic term for breaking content across containers is fragmentation. This module explains how content breaks across fragmentainers such as pages and columns and how such breaks can be controlled by the author.
This module replaces and extends the pagination controls defined in [CSS21] section 13.3 and in [CSS3PAGE].
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.
Each fragmentation break (hereafter, break) ends layout of the fragmented box in the current fragmentainer and causes the remaining content to be laid out in the next fragmentainer, in some cases causing a new fragmentainer to be generated to hold the deferred content. When multiple flows are laid out in parallel, fragmentation is performed independently in each flow.
Breaking a fragmentainer F effectively splits the fragmentainer into two fragmentainers (F1 and F2). The only difference is that the type of break between the two pieces F1 and F2 is the type of break created by the fragmentation context that split F, not the type of break normally created by F's own fragmentation context.
Breaking inline content into lines is another form of
fragmentation, and similarly creates box fragments when it breaks inline
boxes across line boxes.
However, inline breaking is not covered here; see [CSS3TEXT] and the ‘box-decoration-break
’ property in [CSS3BG].
The following sections explain how breaks are controlled in a fragmented flow. Five properties indicate where the user agent may or should break the content flow. In the case of pagination, the author can also specify on which page (left or right) the subsequent content should resume.
break-before
’, ‘break-after
’, ‘break-inside
’ propertiesName: | break-before |
Value: | auto | avoid | always | page | left | right | recto | verso | column | region | avoid-page | avoid-column | avoid-region |
Initial: | auto |
Applies to: | block-level elements, table row groups, table rows (but see prose) |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
Name: | break-after |
Value: | auto | avoid | always | left | right | recto | verso | page | column | region | avoid | avoid-page | avoid-column | avoid-region |
Initial: | auto |
Applies to: | block-level elements, table row groups, table rows (but see prose) |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
Name: | break-inside |
Value: | auto | avoid | avoid-page | avoid-column | avoid-region |
Initial: | auto |
Applies to: | elements that establish formatting contexts, block containers, table row groups, and table rows (but see prose) |
Inherited: | no |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
These properties describe page/column/region break behavior before/after/inside the generated box. These values have the following meaning:
auto
’
avoid
’
always
’
left
’
right
’
recto
’
verso
’
page
’
column
’
region
’
avoid-page
’
avoid-column
’
avoid-region
’
The CSSWG proposes to add two new values
force-any
’
force-all
’
A potential page/column/region break location is typically under the
influence of the containing block's ‘break-inside
’ property, the ‘break-after
’
property of the preceding element, and the ‘break-before
’
property of the following element. When these properties have values other
than ‘auto
’, the forced break values (‘always
’, ‘left
’, ‘right
’, ‘recto
’, ‘verso
’, ‘page
’, ‘column
’ and ‘region
’) take
precedence over the avoid break values
(‘avoid
’, ‘avoid-page
’, ‘avoid-column
’
and ‘avoid-region
’). See the section on rules for breaking for the exact rules on how
these properties affect forced breaks.
User Agents must apply these properties to boxes in the normal flow of the fragmentation root. User agents should also apply these properties to floated boxes whose containing block is in the normal flow of the root fragmented element. User agents may also apply these properties to other boxes.
orphans
’, ‘widows
’Name: | orphans |
---|---|
Value: | <integer> |
Initial: | 2 |
Applies to: | block containers |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
Name: | widows |
---|---|
Value: | <integer> |
Initial: | 2 |
Applies to: | block containers |
Inherited: | yes |
Percentages: | N/A |
Media: | visual |
Computed value: | specified value |
The ‘orphans
’
property specifies the minimum number of line boxes in a block container
that must be left in a fragment before a
fragment break. The ‘widows
’ property specifies the minimum number
of line boxes of a block container that must be left in a fragment after a break. Examples of how they
are used to control fragmentation breaks are given below.
Only positive integers are allowed as values of ‘orphans
’ and ‘widows
’. Negative values
and zero are invalid must cause the declaration to be ignored.
If a block contains fewer lines than the value of ‘widows
’ or ‘orphans
’, the rule
simply becomes that all lines in the block must be kept together.
page-break-before
’, ‘page-break-after
’, and ‘page-break-inside
’ propertiesFor compatibility with CSS Level 2, UAs that
conform to [CSS21]
must alias the ‘page-break-before
’,
‘page-break-after
’, and ‘page-break-inside
’ properties to ‘break-before
’,
‘break-after
’,
and ‘break-inside
’ by treating the ‘page-break-*
’ properties as shorthands for the ‘break-*
’ properties with the following value mappings:
Shorthand (‘page-break-* ’) Values
| Longhand (‘break-* ’) Values
|
---|---|
‘auto | left | right | avoid ’
| ‘auto | left | right | avoid ’
|
‘always ’
| ‘page ’
|
A fragmented flow may be broken across fragmentainers at a number of possible break points. In the case of forced breaks, the UA is required to break the flow at that point. In the case of unforced breaks the UA has to choose among the possible breaks that are allowed.
Some content is not fragmentable, for example many types of replaced elements (such as images or video), scrollable
elements, or a single line of text content. Such content is considered
monolithic: it contains no possible break points.
In addition to any content which is not fragmentable, UAs may consider as
monolithic any elements with ‘overflow
’ set to ‘auto
’
or ‘scroll
’ and any elements with ‘overflow: hidden
’ and a non-‘auto
’ logical height
(and no specified maximum logical height).
Fragmentation splits boxes in the block flow dimension. In block-and-inline flow, breaks may occur at the following places:
Other layout models may add breakpoints to the above classes.
Since breaks are only allowed between siblings (1), not between a box
and its container, a ‘break-before
’ value on a first-child box is
propagated to its container. Likewise a ‘break-after
’ value on a last-child box is
propagated to its container.
The UA is not required to fragment the contents
of monolithic elements, and may instead
either slice the element's graphical representation as necessary to
fragment it or treat its box as unbreakable and overflow the
fragmentainer. In both cases it must treat the element as having ‘break-inside: avoid
’, i.e. only slice or overflow at
the fragmentainer edge if there are no possible
break points on the fragmentainer.
When paginating, if there are no possible break points below the top of the page, and not all the content fits, the UA may break anywhere in order to avoid losing content off the edge of the page.
There are different types of breaks in CSS, defined based on the type of fragmentainers they span:
A fifth type of break is the line break, which is a break between two line boxes. These are not covered in this specification; see [CSS21].
A forced break then occurs at (1) if, among
the ‘break-after
’ properties specified on or
propagated to the earlier sibling box and the ‘break-before
’
properties specified on or propagated to the later sibling box there is at
least one with a forced break value.
When multiple forced break
values apply to a single break point, they combine such all types
of break are honored and no content-empty page boxes are generated, except
for at most one content-empty page as may be required by the forced break values to position
ensuing content on a specific type of page. When ‘left
’, ‘right
’, ‘recto
’, and/or ‘verso
’ are
combined, the value specified on the latest element in the flow wins.
A page break must also occur at (1) if the last line box above this margin and the
first one below it do not have the same value for ‘page
’. See [CSS3PAGE]
When a forced break occurs, it forces ensuing content into the next fragmenter of the type associated with the break, breaking through as many fragmentation contexts as necessary until the specified break types are all satisfied. If the forced break is not contained within a matching type of fragmentation context, then the forced break has no effect.
While breaking controls can force breaks, they can also discourage them. The following rules control whether breaking at a possible break point is allowed:
break-after
’ and ‘break-before
’
values applicable to this break point allow it, which is when at least
one of them forces a break or when all of them are ‘auto
’.
auto
’ and a
common ancestor of all the elements has a ‘break-inside
’
value of ‘avoid
’, then breaking here is not
allowed.
orphans
’ or more, and the number of line
boxes between the break and the end of the box is the value of ‘widows
’ or more.
break-inside
’
property of all ancestors is ‘auto
’.
If the above doesn't provide enough break points to keep content from
overflowing the page boxes, then rules A, B and D are dropped in order to
find additional breakpoints. In this case the UA may use the ‘avoid
’s that are in effect at those points to weigh the
appropriateness of the new breakpoints; however, this specification does
not suggest a precise algorithm.
If that still does not lead to sufficient break points, rule C is dropped as well, to find still more break points.
While CSS3 requires that a fragmented flow must break at allowed break points in order to avoid overflowing the fragmentainers in its fragmentation context, it does not define whether content breaks at a particular allowed break. However, it is recommended that user agents observe the following guidelines (while recognizing that they are sometimes contradictory):
Suppose, for example, that the style sheet contains ‘orphans : 4
’, ‘widows : 2
’,
and there is space for 20 lines (line boxes) available at the bottom of
the current page, and the next block in normal flow is considered for
placement:
widows
’ constraint, and so the second
fragment must contain at least two line boxes; likewise the first
fragment must contain at least four line boxes.
Now suppose that ‘orphans
’ is ‘10
’,
‘widows
’ is
‘20
’, and there are 8 lines available at the
bottom of the current page:
orphans
’ constraint), so it must move as a
block to the next page.
The sizing terminology used in this section is defined in Appendix D of [CSS3-WRITING-MODES].
When a flow is fragmented into varying-size fragmentainers, the following rules are observed for adapting layout:
box-decoration-break: clone
’, if specified, wraps the
fragment with the box's margin in addition to its padding and border.
First page +----------------------------------+ |########### ......... ############| |# # ..... # #| |# left # ....... # right #| |# float # ......... # float #| |# # ........ # #| |# # ......... # #| |# # ........ # #| |#,,,,,,,,,# ......... #,,,,,,,,,,#| +----------------------------------+ Second page +-----------------+ |#`````````# .... | |# left # ... | |# float # .... | |# cont. # .... | |########### ... | |.... #``````````#| |... # right #| |.... # float #| |.... # cont. #| |.... ############| |............... | |....... |
Below are listed some implications of these rules:
Here is an example that shows the use of percentage-based progress:
Suppose we have an absolutely-positioned element that is positioned
‘top: calc(150% + 30px)
’ and has ‘height: calc(100% - 10px)
’. If it is placed into a
paginated context with a first page of 400px, a second page of 200px, and
a third page of 600px, its layout progresses as follows:
When an unforced break occurs between block-level boxes, any margins adjoining the break are truncated. When a forced break occurs there, adjoining margins before the break are truncated, but margins after the break are preserved.
Where a break splits a box, the ‘box-decoration-break
’ property controls whether
the box's margins, borders, padding, and other decorations wrap the
resulting fragments where the split occurs. [CSS3BG]
Move ‘box-decoration-break
’
definition here?
If the box is inline or is a block-level box with its extent specified
as a <length> or <percentage>, then the
fragmented content box ends at the break point and resumes after the
break. Otherwise, the content box extends to fill any remaining fragmentainer
extent before the content resumes (leaving room for any
margins/borders/padding applied by ‘box-decoration-break: clone
’).
Not extending the box to the bottom of the page could be confusing for floats, since they must take up space all the way to the bottom of the page.
In all cases, the extra extent contributed by fragmenting the box (i.e. the distance from the break point to the edge of the fragmentainer) does not consume any specified <length> or <percentage> extent.
slice clone +-----------------+ +-----------------+ | ............... | | ............... | | .............. | | .............. | | ............... | | ............... | | .............. | | .............. | | ............ | | ............ | | ############### | | ############### | | # this box # | | # this box # | | # is # | | # is # | << fixed-height block | # fragmented # | | # fragmented # | | | | ############### | <-+ | | | | | remaining | | | | | blank | | | | | space +-----------------+ +-----------------+ <-+ +-----------------+ +-----------------+ | ............... | | ............... | | .............. | | .............. | | ............... | | ............... | | .............. | | .............. | | ............ | | ............ | | ############### | | ############### | | # this box # | | # this box # | | # is # | | # is # | << auto-height block | # fragmented # | | # fragmented # | | # # | | # # | <-+ | # # | | # # | | remaining | # # | | # # | | blank | # # | | ############### | | space +-----------------+ +-----------------+ <-+
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 Fragmentation is defined for three conformance classes:
A style sheet is conformant to CSS Fragmentation if all of its declarations that use properties defined in this module have values that are valid according to the generic CSS grammar and the individual grammars of each property as given in this module.
A renderer is conformant to CSS Fragmentation if, in addition to interpreting the style sheet as defined by the appropriate specifications, it supports all the features defined by CSS Fragmentation 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 Fragmentation 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.
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.
The following significant changes were made since the 28 February 2012 Working Draft:
recto
’ and ‘verso
’ values to ‘break-before
’ and ‘break-after
’.
break-*
’ and ‘page-break-*
’
properties.
The editors would like to thank Michael Day, Alex Mogilevsky, and Florian Rivoal for their contributions to this module. Special thanks go to the former [CSS3PAGE] editors Jim Bigelow (HP), Melinda Grant (HP), Håkon Wium Lie (Opera), and Jacob Refstrup (HP) for their contributions to this specification, which is a successor of their work there.
Property | Values | Initial | Applies to | Inh. | Percentages | Media |
---|---|---|---|---|---|---|
break-after | auto | avoid | always | left | right | recto | verso | page | column | region | avoid | avoid-page | avoid-column | avoid-region | auto | block-level elements, table row groups, table rows (but see prose) | no | N/A | visual |
break-before | auto | avoid | always | page | left | right | recto | verso | column | region | avoid-page | avoid-column | avoid-region | auto | block-level elements, table row groups, table rows (but see prose) | no | N/A | visual |
break-inside | auto | avoid | avoid-page | avoid-column | avoid-region | auto | elements that establish formatting contexts, block containers, table row groups, and table rows (but see prose) | no | N/A | visual |
orphans | <integer> | 2 | block containers | yes | N/A | visual |
widows | <integer> | 2 | block containers | yes | N/A | visual |