13 Page breaks

Contents

Paged media (e.g., paper, transparencies, pages that are displayed on computer screens, etc.) differ from continuous media in that the content of the document is split into one or more discrete pages.

CSS 2.1 has three properties that indicate where the user agent may or should break pages, and on what page (left or right) the subsequent content should resume. Each page break ends layout in the current page and causes remaining pieces of the document tree to be laid out on a new page.

13.1 Page break properties: 'page-break-before', 'page-break-after', 'page-break-inside'

'page-break-before'
Value:  auto | always | avoid | left | right | inherit
Initial:  auto
Applies to:  block-level elements
Inherited:  no
Percentages:  N/A
Media:  visual, paged
'page-break-after'
Value:  auto | always | avoid | left | right | inherit
Initial:  auto
Applies to:  block-level elements
Inherited:  no
Percentages:  N/A
Media:  visual, paged
'page-break-inside'
Value:  avoid | auto | inherit
Initial:  auto
Applies to:  block-level elements
Inherited:  yes
Percentages:  N/A
Media:  visual, paged

Values for these properties have the following meanings:

auto
Neither force nor forbid a page break before (after, inside) the generated box.
always
Always force a page break before (after) the generated box.
avoid
Avoid a page break before (after, inside) the generated box.
left
Force one or two page breaks before (after) the generated box so that the next page is formatted as a left page.
right
Force one or two page breaks before (after) the generated box so that the next page is formatted as a right page.

Whether the first page of a document is a left page or a right page is not defined in this specification. A conforming user agent may interpret the values 'left' and 'right' as 'always'.

A potential page break location is typically under the influence of the parent element's 'page-break-inside' property, the 'page-break-after' property of the preceding element, and the 'page-break-before' property of the following element. When these properties have values other than 'auto', the values 'always', 'left', and 'right' take precedence over 'avoid'.

These properties only apply to non-floating block-level elements. Also, page breaks cannot be forced to occur inside table cells, absolutely positioned boxes, and fixed positioned boxes. Page breaks set before, inside, or after such elements must be ignored.

13.2 Allowed page breaks

In the normal flow, page breaks can occur at the following places:

  1. In the vertical margin between block boxes. When a page break occurs here, the computed values of the relevant 'margin-top' and 'margin-bottom' properties are set to '0'.
  2. Between line boxes inside a block box.

These breaks are subject to the following rules:

If the above rules do not provide enough break points to keep content from overflowing the page boxes, then rules B and C are dropped in order to find additional breakpoints. If that still does not lead to sufficient break points, rule A is dropped as well.

13.3 Forced page breaks

A page break must occur at (1) if, among the 'page-break-after' and 'page-break-before' properties of all the elements generating boxes that meet at this margin, there is at least one with the value 'always', 'left', or 'right'.

13.4 "Best" page breaks

CSS 2.1 does not define which of a set of allowed page breaks must be used; CSS 2.1 does not forbid a user agent from breaking at every possible break point, or not to break at all. But CSS 2.1 does recommend that user agents observe the following heuristics (while recognizing that they are sometimes contradictory):