8000 csswg-drafts/css-break/Overview.bs at 8b45a0d06d95889b435e7e75194b8732977271e6 · w3c/csswg-drafts · GitHub
Skip to content
8000

Latest commit

 

History

History
1233 lines (1118 loc) · 47.9 KB

File metadata and controls

1233 lines (1118 loc) · 47.9 KB
<h1>CSS Fragmentation Module Level 3</h1>
<h2 id=tagline class="no-num no-toc">Breaking the Web, one fragment at a time</h2>
<pre class='metadata'>
Status: ED
Work Status: Refining
ED: http://dev.w3.org/csswg/css-break/
Shortname: css-break
Group: csswg
Level: 3
TR: http://www.w3.org/TR/css-break-3/
Previous Version: http://www.w3.org/TR/2015/WD-css3-break-20150129/
Editor: Rossen Atanassov, Microsoft, ratan@microsoft.com<
Editor: fantasai, Invited Expert, http://fantasai.inkedblade.net/contact
Abstract: This module describes the fragmentation model that partitions a flow into pages, columns, or regions.
Abstract: It builds on the Page model module and introduces and defines the fragmentation model.
Abstract: It adds functionality for pagination, breaking variable fragment size and orientation, widows and orphans.
Ignored Terms: background positioning area, region chain
Use <i> Autolinks: yes
</pre>
<h2 id="intro">
Introduction</h2>
<p><em>This section is not normative.</em></p>
<p>
In paged media (e.g., paper, transparencies, photo album pages, pages
displayed on computer screens as printed output simulations), as
opposed to <a href="http://www.w3.org/TR/CSS2/media.html#continuous-media-group">
continuous media</a>, 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 <dfn>pagination</dfn>.
</p>
<p>
In CSS, in addition to paged media, certain layout features such as
<a href="http://www.w3.org/TR/css3-regions/">regions</a> [[CSS3-REGIONS]]
and <a href="http://www.w3.org/TR/css3-multicol/">multi-column layout</a>
[[CSS3COL]] create a similarly fragmented environment.
The generic term for breaking content across containers is
<i>fragmentation</i>.
This module explains how content breaks across <i>fragmentation containers</i> (<i>fragmentainers</i>)
such as pages and columns and how such breaks can be
<a href="#breaking-controls">controlled by the author</a>.
</p>
<h3 id="placement">
Module Interactions</h3>
<p>
This module replaces and extends the pagination controls defined in
[[CSS21]] <a href="http://www.w3.org/TR/CSS21/page.html#page-breaks">section 13.3</a>
and in [[CSS3PAGE]].
</p>
<!-- End section "Modules Interactions" -->
<h3 id="values">
Values</h3>
<p>
This specification follows the <a href="http://www.w3.org/TR/CSS21/about.html#property-defs">
CSS property definition conventions</a> 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 [[CSS3VAL]],
when combined with this module, adds the ''initial'' value
to the properties defined here.</p>
<p>
In addition to the property-specific values listed in their definitions, all properties
defined in this specification also accept the <a href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit">
inherit</a> keyword as their property value. For readability it has not been
repeated explicitly.
</p>
<h2 id="fragmentation-model">
Fragmentation Model and Terminology</h2>
<dl export>
<dt><dfn>fragmentation container</dfn> (<dfn>fragmentainer</dfn>)</dt>
<dd>
A box&mdash;such as a page box, column box, or region&mdash;that contains
a portion (or all) of a <i>fragmented flow</i>.
Fragmentainers can be pre-defined, or generated as needed.
When breakable content overflows a fragmentainer in the block dimension,
instead of overflowing it breaks into the next container in its
<i>fragmentation context</i>.
</dd>
<dt><dfn>fragmentation context</dfn></dt>
<dd>
An ordered series of <i>fragmentainers</i>,
such as created by a <a href="http://www.w3.org/TR/css3-multicol/">multi-column element</a>,
a chain of <a href="http://www.w3.org/TR/css3-regions">CSS regions</a>,
or a <a href="http://www.w3.org/TR/css3-page/">paged media display</a>.
A given fragmentation context can only have one block flow direction
across all its <i>fragmentainers</i>.
(Descendants of the <i>fragmentation root</i> may have other block flow directions,
but fragmentation proceeds according to the block flow direction applied to the <i>fragmentation root</i>.)
</dd>
<dt><dfn>fragmented flow</dfn></dt>
<dd>
A content flow that is being laid out in a <i>fragmentation context</i>.
The <i>fragmented flow</i> consists of the content of a (possibly anonymous) box
called the <dfn>fragmentation root</dfn>.
</dd>
<dt><dfn>fragmentation direction</dfn></dt>
<dd>
The block flow direction of the <i>fragmentation context</i>,
i.e. the direction in which content is fragmented.
(In this level of CSS, content only fragments in one dimension.)
</dd>
<dt><dfn>fragmentation</dfn></dt>
<dd>
The process of splitting a content flow across the <i>fragmentainers</i>
that form a <i>fragmentation context</i>.
</dd>
<dt><dfn>box fragment</dfn> or <dfn>fragment</dfn></dt>
<dd>
The portion of a box that belongs to exactly one <i>fragmentainer</i>.
A box in continuous flow always consists of only one fragment.
A box in a fragmented flow consists of one or more fragments.
<dt><dfn>remaining fragmentainer extent</dfn></dt>
<dd>
The remaining <i>block-axis</i> space in the <i>fragmentainer</i> available to a given element,
i.e. between the end of preceding content in <i>fragmentainer</i>
and the edge of the <i>fragmentainer</i>.
</dl>
<p>
Each <dfn>fragmentation break</dfn> (hereafter, <dfn>break</dfn>)
ends layout of the fragmented box in the current <i>fragmentainer</i>
and causes the remaining content to be laid out in the next <i>fragmentainer</i>,
in some cases causing a new <i>fragmentainer</i> to be generated
to hold the deferred content.
</p>
<p class="note">
Breaking inline content into lines is another form of fragmentation,
and similarly creates box fragments when it breaks
<a href="http://www.w3.org/TR/CSS21/visuren.html#inline-boxes">inline boxes</a>
across <a href="http://www.w3.org/TR/CSS21/visuren.html#line-box">line boxes</a>.
However, inline breaking is not covered here; see [[!CSS21]]/[[CSS3TEXT]].
</p>
<h3 id="parallel-flows">
Parallel Fragmentation Flows</h3>
<p>
When multiple flows are laid out parallel to each other,
fragmentation is performed independently in each flow.
For example, if an element is floated,
then a forced break inside the float
will not affect the content wrapping outside the float
(except insofar as it may increase the height of the float).
</p>
<p>
The following are examples of parallel flows
whose contents will fragment independently:
</p>
<ul>
<li>The contents of a float vs. the content wrapping outside the float.
<li>The contents of a float vs. the contents of an adjacent float.
<li>The contents of each table cell in a single table row.
<li>The contents of each grid item in a single grid row.
<li>The contents of each flex item in a flex layout row.
<li>The contents of absolutely-positioned elements
that cover the same range of their containing block's fragmentation context.
</ul>
<p>
Content overflowing the content edge of a fixed-size box
is considered parallel to the content after the fixed-size box
and follows the normal fragmentation rules.
Although overflowing content doesn't affect the size of the <i>fragmentation root</i> box,
it does increase the length of the <i>fragmented flow</i>,
spilling into or generating additional <i>fragmentainers</i> as necessary.
</p>
<h3 id="nested-flows">
Nested Fragmentation Flows</h3>
<p>
Breaking a <i>fragmentainer</i> <var>F</var> effectively splits the <i>fragmentainer</i>
into two <i>fragmentainers</i> (<var>F<sub>1</sub></var> and <var>F<sub>2</sub></var>).
The only difference is that,
with regards to the content of <i>fragmentainer</i> <var>F</var>,
the type of break
between the two pieces <var>F<sub>1</sub></var> and <var>F<sub>2</sub></var>
is the <a href="#break-types">type of break</a> created
by the <i>fragmentation context</i> that split <var>F</var>,
not the type of break normally created by <var>F</var>’s own <i>fragmentation context</i>.
</p>
<div class="example">
For example, if a region box is broken at a page boundary,
then the content of the region will be affected by a page break at that point
(but not by a region break).
</div>
<div class="note">
Note that when a multi-column element breaks across pages,
it generates a new row of columns on the next page for the rest of its content,
so that a page break within a multi-column element
is always both a page break and a column break.
</div>
<h2 id="breaking-controls">
Controlling Breaks</h2>
<p>
The following sections explain how breaks are controlled in a <i>fragmented flow</i>.
A page/column/region break opportunity between two boxes
is 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.
A page/column/region break opportunity between line boxes
is under the influence of
the containing block's 'break-inside', 'widows', and 'orphans' properties.
A fragmentation break can be
allowed, forced, or discouraged depending on the values of these properties.
A forced break overrides any break restrictions acting at that break point.
In the case of forced page breaks, the author can also specify
on which page (<a href="http://www.w3.org/TR/css3-page/#left-right-first">left or right</a>)
the subsequent content should resume.
<p>
See the section on <a href="#breaking-rules">rules for breaking</a>
for the exact rules on how these properties affect fragmentation.
<h3 id="break-between">
Breaks Between Boxes: the 'break-before' and 'break-after' properties</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>break-before</dfn>, <dfn>break-after</dfn>
<tr>
<th>Value:
<td>auto | avoid | always | any |
avoid-page | page | left | right | recto | verso |
avoid-column | column | avoid-region | region
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>block-level elements, table row groups, table rows (but see prose)
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed&nbsp;value:
<td>specified value
</table>
<p>
These properties specify page/column/region break behavior
before/after the generated box.
The <dfn>forced break values</dfn>
''always'', ''any'', ''left'', ''right'', ''recto'', ''verso'', ''page'', ''column'' and ''region''
create a <a href="#forced-breaks">forced break</a> in the flow
while the <dfn>avoid break values</dfn>
''break-before/avoid'', ''break-before/avoid-page'', ''break-before/avoid-column'' and ''break-before/avoid-region''
indicate that content should be kept together.
</p>
<p>
Since breaks are only allowed between siblings,
not between a box and its container (see <a href="#possible-breaks">Possible Break Points</a>),
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.
(Conflicting values <a href="#forced-breaks">combine</a> as defined below.)
This propagation stops before it breaks through the nearest matching fragmentation context.
</p>
<p>
Values for 'break-before' and 'break-after' are defined in the sub-sections below.
User Agents must apply these properties to boxes in the normal flow of the <i>fragmentation root</i>.
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.
</p>
<h4 id="generic-break-values" class="no-num">
Generic Break Values</h4>
<p>
These values have an effect regardless of
the type of fragmented context containing the flow.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>auto</dfn>
<dd>
Neither force nor forbid a break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
<dt><dfn>avoid</dfn>
<dd>
Avoid a break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
<dt><dfn>always</dfn>
<dd>
Always force a break
(of all possible types, through all fragmentation contexts)
before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
<dt><dfn>any</dfn>
<dd>
Force a break of any type, whichever is the type of the deepest fragmentation context,
before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
</dl>
<h4 id="page-break-values" class="no-num">
Page Break Values</h4>
<p>
These values only have an effect in paginated contexts;
if the flow is not paginated, they have no effect.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>avoid-page</dfn>
<dd>
Avoid a page break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
<dt><dfn>page</dfn>
<dd>
Always force a page break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
<dt><dfn>left</dfn>
<dd>
Force one or two page breaks before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a> so that the next page is formatted as a left page.
</dd>
<dt><dfn>right</dfn>
<dd>
Force one or two page breaks before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a> so that the next page is formatted as a right page.
</dd>
<dt><dfn>recto</dfn>
<dd>
Force one or two page breaks before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a> so that
the next page is formatted as either a left page or a right page,
whichever is second (according to the <i>page progression</i>) in a page spread.
</dd>
<dt><dfn>verso</dfn>
<dd>
Force one or two page breaks before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes"&g 1F7D t;principal box</a> so that
the next page is formatted as either a left page or a right page,
whichever is first (according to the <i>page progression</i>) in a page spread.
</dd>
</dl>
<h4 id="column-break-values" class="no-num">
Column Break Values</h4>
<p>
These values only have an effect in multi-column contexts;
if the flow is not within a multi-column context, they have no effect.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>avoid-column</dfn>
<dd>
Avoid a column break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
<dt><dfn>column</dfn>
<dd>
Always force a column break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
</dl>
<h4 id="region-break-values" class="no-num">
Region Break Values</h4>
<p>
These values only have an effect in multi-region contexts;
if the flow is not linked across multiple regions, these values have no effect.
<dl dfn-type=value dfn-for='break-before,break-after'>
<dt><dfn>avoid-region</dfn>
<dd>
Avoid a region break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
<dt><dfn>region</dfn>
<dd>
Always force a region break before/after the <a href="http://www.w3.org/TR/CSS21/visuren.html#block-boxes">principal box</a>.
</dd>
</dl>
<h3 id="break-within">
Breaks Within Boxes: the 'break-inside' property</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>break-inside</dfn>
<tr>
<th>Value:
<td>auto | avoid | avoid-page | avoid-column | avoid-region
<tr>
<th>Initial:
<td>auto
<tr>
<th>Applies to:
<td>elements in the normal flow that establish formatting contexts,
or that are block containers, table row groups, or table rows
<tr>
<th>Inherited:
<td>no
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed&nbsp;value:
<td>specified value
</table>
<p>
This property specifies page/column/region break behavior
within the element's principal box.
Values have the following meanings:
<dl dfn-type=value dfn-for='break-inside,page-break-inside'>
<dt><dfn>auto</dfn>
<dd>
Impose no additional breaking constraints within the box.
</dd>
<dt><dfn>avoid</dfn>
<dd>
Avoid breaks within the box.
</dd>
<dt><dfn>avoid-page</dfn>
<dd>
Avoid a page break within the box.
</dd>
<dt><dfn>avoid-column</dfn>
<dd>
Avoid a column break within the box.
</dd>
<dt><dfn>avoid-region</dfn>
<dd>
Avoid a region break within the box.
</dd>
</dl>
<h3 id="widows-orphans">
Breaks Between Lines: 'orphans', 'widows'</h3>
<table class="propdef">
<tr>
<th>Name:
<td><dfn>orphans</dfn>, <dfn>widows</dfn>
<tr>
<th>Value:
<td>&lt;integer&gt;
<tr>
<th>Initial:
<td>2
<tr>
<th>Applies to:
<td>block containers
<tr>
<th>Inherited:
<td>yes
<tr>
<th>Percentages:
<td>N/A
<tr>
<th>Media:
<td>visual
<tr>
<th>Computed value:
<td>specified value
</table>
<p>
The 'orphans' property specifies the minimum number
of line boxes in a block container
that must be left in a <i>fragment</i> <em>before</em> a fragmentation break.
The 'widows' property specifies the minimum number
of line boxes of a block container
that must be left in a <i>fragment</i> <em>after</em> a break.
Examples of how they are used to control fragmentation breaks are given
<a href="#widows-orphans-example">below</a>.
</p>
<p>
Only positive integers are allowed as values of 'orphans' and 'widows'.
Negative values and zero are invalid and must cause the declaration to be
<a href="http://www.w3.org/TR/CSS21/conform.html#ignore">ignored</a>.
</p>
<p>
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.
</p>
<h3 id="page-break-properties">
Page Break Aliases: the 'page-break-before', 'page-break-after', and 'page-break-inside' properties</h3>
<p>For compatibility with <a href="http://www.w3.org/TR/CSS21/page.html">CSS Level 2</a>,
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:
<table class="data">
<thead>
<tr><th>Shorthand ('page-break-*') Values
<th>Longhand ('break-*') Values
</thead>
<tbody>
<tr><td><css>auto | left | right | avoid</css>
<td><css>auto | left | right | avoid</css>
<tr><td><css>always</css>
<td><css>page</css>
</tbody>
</table>
<h2 id="breaking-rules">
Rules for Breaking</h2>
<p>
A fragmented flow may be broken across fragmentainers at a number of
<a href="#possible-breaks">possible break points</a>. In the case of
<a href="#forced-breaks">forced breaks</a>, the UA is required to
break the flow at that point. In the case of
<a href="#unforced-breaks">unforced breaks</a>, the UA has to choose
among the possible breaks that are allowed.
</p>
<p>
Some content is not fragmentable, for example many types of
<a href="http://www.w3.org/TR/CSS21/conform.html#replaced-element">replaced elements</a> [[!CSS21]] (such as images or video),
scrollable elements, or a single line of text content.
Such content is considered <dfn>monolithic</dfn>:
it contains no possible break points.
In addition to any content which is not fragmentable,
UAs may consider as <i>monolithic</i> any elements with
'overflow' set to ''overflow/auto'' or ''overflow/scroll'' and
any elements with ''overflow: hidden'' and a non-''height/auto''
<a href="http://www.w3.org/TR/css3-writing-modes/#block-size">logical height</a>
(and no specified maximum logical height).
<p>
To guarantee progress, fragmentainers are assumend to have a minimum
<i>block size</i> of 1px regardless of their used size.
<h3 id="possible-breaks">
Possible Break Points</h3>
<p>
Fragmentation splits boxes in the block flow dimension.
In block-and-inline flow, breaks may occur at the following places:
</p>
<dl>
<dt id="btw-blocks">Class A</dt>
<dd>
Between sibling boxes of the following types:
<dl>
<dt>Block-parallel Fragmentation</dt>
<dd>
When the block flow direction of the siblings' containing block
is parallel to that of the fragmentation context:
<a href="http://www.w3.org/TR/2011/REC-CSS2-20110607/visuren.html#positioning-scheme">in-flow</a> block-level boxes,
a float and an immediately-adjacent in-flow or floated box,
table row group boxes,
table row boxes,
multi-column column row boxes.
</dd>
<dt>Block-perpendicular Fragmentation</dt>
<dd>
When the block flow direction of the siblings' containing block
is perpendicular to that of the fragmentation context:
table column group boxes,
table column boxes,
multi-column column boxes.
</dd>
</dl>
<dt id="btw-lines">Class B</dt>
<dd>
Between line boxes inside a block container box.
</dd>
<dt id="end-block">Class C</dt>
<dd>
Between the content edge of a block container box and the outer edges of its
child content (margin edges of block-level children or line box
edges for inline-level children) <em>if</em> there is a (non-zero)
gap between them.
<!-- XXX add example -->
</dd>
</dl>
<p class="note">
There is no inherent prioritization among these classes of break points.
However, individual break points may be prioritized or de-prioritized
by using the <a href="#breaking-controls">breaking controls</a>.
<p id=monolithic-breaking>
The UA is not required to fragment the contents of <i>monolithic</i> elements,
and may instead slice the element's graphical representation
as necessary to fragment it.
In this case it must treat the element as having ''break-inside: avoid'',
i.e. only slice or overflow at the fragmentainer edge
if there are no other <a href="#possible-breaks">possible break points</a>
in the fragmentainer.
</p>
<p>
When fragmenting, if there are no possible break points below the top
of the fragmentainer, and not all the content fits, the UA may break anywhere
in order to avoid losing content off the edge of the fragmentainer.
</p>
<p class="note">
Other layout models may add breakpoints to the above classes.
For example, [[CSS3-FLEXBOX]] adds certain points within a flex formatting context
to classes A and C.
</p>
<h3 id="break-types">
Types of Breaks</h3>
<p>
There are different types of breaks in CSS, defined based on the type of
fragmentainers they span:
</p>
<dl>
<dt><dfn>page break</dfn></dt>
<dd>
A break between two <a href="http://www.w3.org/TR/css3-page/#page-box">page boxes</a>.
[[!CSS3PAGE]]
</dd>
<dt><dfn>spread break</dfn></dt>
<dd>
A break between two page boxes that are not associated with
<a href="http://www.w3.org/TR/css3-page/#facing-pages">facing pages</a>.
A spread break is always also a page break.
[[!CSS3PAGE]]
</dd>
<dt><dfn>column break</dfn></dt>
<dd>
A break between two <a href="http://www.w3.org/TR/css3-multicol/#column-box">column boxes</a>.
Note that if the column boxes are on different pages, then the break is
also a <i>page break</i>.
Similarly, if the column boxes are in different regions,
then the break is also a <i>region break</i>.
[[!CSS3COL]]
</dd>
<dt><dfn>region break</dfn></dt>
<dd>
A break between two <a href="http://www.w3.org/TR/css3-regions/#regions">regions</a>.
Note that if the region boxes are on different pages, then the break is
also a <i>page break</i>.
[[!CSS3-REGIONS]]
</dd>
</dl>
<p class="note">
A fifth type of break is the <dfn>line break</dfn>, which is a break between
two <a href="http://www.w3.org/TR/CSS21/visuren.html#line-box">line boxes</a>.
These are not covered in this specification; see [[!CSS21]] [[CSS3TEXT]].
</p>
<h3 id="forced-breaks">
Forced Breaks</h3>
<p>
A <dfn>forced break</dfn> is one explicitly indicated by the style sheet author.
A <i>forced break</i> occurs at a <a href="#btw-blocks">class A break point</a> 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 <i>forced break value</i>.
(Thus a <i>forced break value</i> effectively overrides any <i>avoid break value</i>
that also applies at that break point.)
</p>
<p>
When multiple <i>forced break values</i> apply to a single break point,
they combine such that all types of break are honored.
When ''left'', ''right'', ''recto'', and/or ''verso'' are combined,
the value specified on the latest element in the flow wins.
</p>
<p class="note">
A forced page break must also occur at a <a href="#btw-blocks">class A break point</a>
if the last line box above this margin and the first one below it do not have the
same value for 'page'. See [[!CSS3PAGE]]
</p>
<p>
When a forced break occurs,
it forces ensuing content into the next fragmentainer 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.
<h3 id="unforced-breaks">
Unforced Breaks</h3>
<p>
While <a href="#breaking-controls">breaking controls</a> can force breaks,
they can also discourage them.
An <dfn>unforced break</dfn> is one that is inserted automatically by the UA
in order to prevent content from overflowing the <i>fragmentainer</i>.
The following rules control whether unforced breaking
at a <a href="#possible-breaks">possible break point</a> is allowed:
</p>
<dl>
<dt>Rule 1</dt>
<dd>
A fragmented flow may break at a <a href="#btw-blocks">class A break point</a> only if
all the '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 ''break-before/auto''.
</dd>
<dt>Rule 2</dt>
<dd>
However, if all of them are ''break-before/auto'' and a common ancestor of all
the elements has a 'break-inside' value of ''break-inside/avoid'', then breaking
here is not allowed.
</dd>
<dt>Rule 3</dt>
<dd>
Breaking at a <a href="#btw-lines">class B break point</a> is allowed only if the number
of line boxes between the break and the start of the enclosing block
box is the value of '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.
</dd>
<dt>Rule 4</dt>
<dd>
Additionally, breaking at <a href="#btw-blocks">class B</a> or
<a href="#end-block">class C</a> break points
is allowed only if the 'break-inside' property of all ancestors is ''break-inside/auto''.
</dd>
</dl>
<p>
If the above doesn't provide enough break points to keep content from
overflowing the <i>fragmentainer</i>,
then rules 1, 2 and 4 are dropped in order to find additional breakpoints.
In this case the UA may use the <css>avoid</css>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.
</p>
<p>
If that still does not lead to sufficient break points, rule 3 is
dropped as well, to find still more break points.
</p>
<p class="issue">This means that 'widows' and 'orphans' restrictions
are given priority over the 'break-*' controls. Is this appropriate?
<h3 id="best-breaks">
Optimizing Unforced Breaks</h3>
<p>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 <a href="#unforced-breaks">allowed break</a>.
However, it is recommended that user agents observe the following
guidelines (while recognizing that they are sometimes contradictory):
</p>
<ul>
<li>Break as few times as possible.</li>
<li>Make all fragmentainers that don't end with a forced break appear
to be equally filled with content.</li>
<li>Avoid breaking inside a replaced element.</li>
</ul>
<div class="example" id="widows-orphans-example">
<p>
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:
</p>
<ul>
<li>
If the block contains 20 line boxes or fewer, it should be placed
on the current page.
</li>
<li>
If the block contains 21 or 22 line boxes, the second fragment of
the paragraph must not violate the '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.
</li>
<li>
If the block contains 23 line boxes or more, the first fragment should
contain 20 lines and the second fragment the remaining lines. But if
any fragment of the block is placed on the current page, that fragment
must contain at least four line boxes and the second fragment at least
two line boxes.
</li>
</ul>
<p>
Now suppose that 'orphans' is ''10'', 'widows' is ''20'', and there
are 8 lines available at the bottom of the current page:
</p>
<ul>
<li>
If the block contains 8 lines or fewer, it should be placed
on the current page.
</li>
<li>
If the block contains 9 lines or more, it must NOT be split
(that would violate the 'orphans' constraint), so it must
move as a block to the next page.
</li>
</ul>
</div>
<h2 id="breaking-boxes">
Box Model for Breaking</h2>
<p class="note">
The sizing terminology used in this section is defined in [[CSS3-SIZING]].
</p>
<h3 id="varying-size-boxes">
Breaking into Varying-size Fragmentainers</h3>
<p>
When a flow is fragmented into varying-size fragmentainers, the following
rules are observed for adapting layout:
</p>
<!-- try to make this clearer. Steve suggests swapping first two points, maybe break it up more? -->
<ul>
<li>
Intrinsic sizes are calculated and maintained across the entire element.
Where an initial containing block size is needed to resolve an intrinsic
size, assume the size of the first fragmentainer defining a fragmentation context.
</li>
<li>
Layout is performed per-fragmentainer, with each fragmentainer continuing
progress from the breakpoint on the previous, but recalculating sizes
and positions using its own size as if the entire element were fragmented
across fragmentainers of this size. Progress is measured in percentages
(not absolute lengths) of used/remaining fragmentainer extent and in amount of
used/remaining content.
However, when laying out <i>monolithic</i> elements,
the UA may instead maintain a consistent <i>inline size</i> and resolved <i>block size</i>
across fragmentainers.
</li>
<li>
Fragments of boxes that began on a previous fragm 2A19 entainer must obey
placement rules with the additional constraint that fragments must
not be positioned above the <i>block-start</i> edge of the fragmentainer.
If this results in a box's continuation fragment
shifting away from the <i>block-start</i> edge of the fragmentainer, then
''box-decoration-break: clone'', if specified, wraps the fragment
with the box's margin in addition to its padding and border.
<div class="figure">
<pre>First page
<!-- -->+----------------------------------+
<!-- -->|########### ......... ############|
<!-- -->|# # ..... # #|
<!-- -->|# left # ....... # right #|
<!-- -->|# float # ......... # float #|
<!-- -->|# # ........ # #|
<!-- -->|# # ......... # #|
<!-- -->|# # ........ # #|
<!-- -->|#,,,,,,,,,# ......... #,,,,,,,,,,#|
<!-- -->+----------------------------------+
<!-- -->
<!-- -->Second page
<!-- -->
<!-- -->+-----------------+
<!-- -->|#`````````# .... |
<!-- -->|# left # ... |
<!-- -->|# float # .... |
<!-- -->|# cont. # .... |
<!-- -->|########### ... |
<!-- -->|.... #``````````#|
<!-- -->|... # right #|
<!-- -->|.... # float #|
<!-- -->|.... # cont. #|
<!-- -->|.... ############|
<!-- -->|............... |
<!-- -->|....... |</pre>
</div>
</li>
</ul>
<p class="note">
Since document order of elements doesn't change during fragmentation,
fragments are processed following the same rules that apply to continuous
media. In particular, the order of floats is preserved across all
fragments and follows the same rules as defined in CSS 2.1 9.5.
</p>
<p>Below are listed (informatively) some implications of these rules:</p>
<ul>
<li>
Boxes (including tables) fullfilling layout constraints at their
<i lt='fill-available size'>fill-available</i> or percentage-based size
may change <i>inline size</i> across pages.
</li>
<li>
Boxes (including tables) fulfilling layout constraints at their
<i lt="min-content size">min-content</i>, <i lt="max-content size">max-content</i>, or absolute-length size
will maintain their <i>inline size</i> across pages.
</li>
<li>
A block-level continuation fragment may be placed below the top of
the page if, e.g. it establishes a block formatting context and
is placed beside a float and both it and the float continue onto
a narrower page that is too narrow to hold both of them side-by-side.
</li>
<li>
An element adjacent to a preceding float on one page may wind up above
the float's continuation on the next page if,
e.g. that float is pushed down because
it no longer fits side-by-side with an earlier float
that also continues onto this narrower page.
</li>
<li>
A left float may appear on a page <em>before</em>
the remaining fragments of a preceding right float
if that right float does not fit on the earlier page.
However another right float will be forced down until
the preceding right float's remaining fragment can be placed.
</ul>
<div class="example">
<p>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 height of 400px,
a second page of 200px, and a third page of 600px, its layout progresses
as follows:
<ul>
<li>First, the top position is resolved against the height of the first page.
This results in 630px. Since the first page has a height of only 400px, layout
moves to the second page, recording progress of 400/630 = 63.49% with
36.51% left to go.
<li>Now on the second page, the top position is again resolved, this
time against the height of the second page. This results in 330px. The
remaining 36.51% of progress thus resolves to 120.5px, placing the top edge of
the element 120.5px down the second page.
<li>Now the height is resolved against the second page; it resolves
to 190px. Since there are only 79.5px left on the page, layout moves
to the third page, recording progress of 79.5/190 = 41.84%, with 58.16%
left to go.
<li>On the third page, the height resolves to 590px. The remaining
58.16% of progress thus resolves to 343.1px, which fits on this page
and completes the element.
</ul>
</div>
<h3 id="break-margins">
Adjoining Margins at Breaks</h3>
<p>
When an unforced break occurs between block-level boxes,
any margins adjoining the break truncate to the <i>remaining fragmentainer extent</i>.
When a forced break occurs there, adjoining margins before the break are truncated,
but margins after the break are preserved.
</p>
<h3 id="box-splitting">
Splitting Boxes</h3>
<p>
When a box breaks,
its content box extends to fill any <i>remaining fragmentainer extent</i>
(leaving room for any margins/borders/padding applied by ''box-decoration-break: clone'')
before the content resumes on the next <i>fragmentainer</i>.
(A <i>fragmentation break</i> that pushes content to the next <i>fragmentainer</i>
effectively increases the <i>block size</i> of a box's contents.)
<p class="note">
The extra <i>block size</i> contributed by fragmenting the box
(i.e. the distance from the break point to the edge of the <i>fragmentainer</i>)
contributes progress towards any specified limits on the box's <i>block size</i>.
<div class="figure">
<p class="caption">
The diagrams below illustrate filling the <i>remaining fragmentainer extent</i>.
</p>
<pre>
+-----------------+ +-----------------+
| ............... | | ............... |
| .............. | | .............. |
| ............... | | ............... |
| .............. | | .............. |
| ............ | | ............ |
| ############### | | ############### |
| # this box # | | # this box # |
| # is # | | # is # | &lt;&lt; auto-height block