page-break-after, page-break-beforeNN n/a   IE 4   CSS 2
 Inherited: No
 

Defines how content should treat a page break around an element when the document is sent to a printer. Page breaks are not rendered in the visual browser as they may be in word processing programs; on screen, long content flows in one continuous scroll.

Page breaks (and related attributes such as widows and orphans) are handled more fully in CSS2 than as deployed in Internet Explorer 4. Proper handling of pages for printers relies on the CSS2 concept of the page box, which is a rectangular region that ultimately reaches a printed page. Page break style attributes help the browser control the precise content of each page box. Without any assistance (or with the auto setting), the browser divides pages for printing much as it has in the past by doing a best-fit for the content to fill up as much of each page as there is space for it.

To force a page break above an element, associate a page-break-before:always style setting with the element. Similarly, to force a break after an element, use page-break-after:always. For example, if you want a special class of BR elements to break after them, you could set up a class selector style rule as follows:

<STYLE TYPE="text/css"> BR.pageEnd {page-break-after: always} </STYLE>

Then, whenever you want to force a page break in the document, include the following tag:

<BR CLASS="pageEnd">

Attribute settings for left and right assume that the browser is equipped to detect left-facing from right-facing pages for double-sided printing (as specified in CSS2). Because you are likely to set different margins for each side of the gutter, indicating how pages break to start a new section requires forcing sufficient page breaks to plant new sections on the desired page. For example, if you want each H1 element to begin on a right-facing page, you would set a page break style for it as follows:

H1 {page-break-before: right}

This attribute forces the browser to at least one and at most two page breaks before the H1 element to make sure it starts on a right-facing page. When the browser generates a second page break for the left or right value, it means that the browser generates a blank page box for the second page break.

 
CSS Syntax
page-break-after: breakType page-break-before: breakType
 
Value
Internet Explorer 4 recognizes four constant values: always | auto | left | right. CSS2 adds avoid, which urges the browser to avoid breaking the page in that element if at all possible.
 
Initial Value
auto
 
Example
DIV.titlePage {page-break-before: always; page-break-after: always}
 
Applies To
All elements except inline table elements TD and TH.
 
Object Model Reference
IE [window.]document.all.elementID.style.pageBreakAfter
[window.]document.all.elementID.style.pageBreakBefore