page-break-after Attribute | pageBreakAfter Property
Gets or sets a value indicating whether a page break occurs after the object.
Syntax
CSS { page-break-after : sBreak } Scripting [ sBreak = ] object.style.pageBreakAfter
Possible Values
sBreak String that specifies or receives one of the following values.
always- Always insert a page break after the object.
- auto
- Default. Neither force nor forbid a page break after the object.
avoid- Windows Internet Explorer 8. Forbid a page break after the object, if possible.
empty string- Behaves the same as
auto.inherit- Internet Explorer 8. Inherit the value of the same property for the object's parent.
left- Currently behaves the same as
always.right- Currently behaves the same as
always.The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of auto. The Cascading Style Sheets (CSS) attribute is not inherited.
DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are supported in IE7 Standards mode and IE5 (Quirks) mode only. For more information, see About Dynamic Properties and Defining Document Compatibility.
Remarks
This property applies when printing the document. This property does not apply to the BR or HR elements.
If there are conflicts between this property and the pageBreakBefore value on the object previously displayed in the browser, the value that results in the largest number of page breaks is used.
Page breaks are not permitted inside positioned objects.
Examples
The following examples use the page-break-after attribute and the pageBreakAfter property to start printing on a new page.This example uses the p element as a selector in an embedded style sheet to break the page at the end of all paragraphs.
<html> <head> <style type="text/css"> P { page-break-after: always; } </style> </head> <body> <p> : </p> </body> </html>Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/page-break-after.htm
This example uses a button to turn off the page break after the object that has an ID value of oPrgrph. When the page is printed or previewed, a page break occurs after the first paragraph unless the user clicks the button.
<html> <body> <p id="oPrgrph" style="page-break-after: always;">If you print (or preview) this page, there will be a page-break after this paragraph, unless you click the button.</p> <!-- CLICKING ON THIS BUTTON TURNS OFF BREAK --> <button onclick="oPrgrph.style.pageBreakAfter=''">Turn Off Break</button> </body> </html>Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/pagebreakAfter.htm
Standards Information
This property is defined in Cascading Style Sheets (CSS), Level 2 (CSS2).
Applies To
BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CSSStyleDeclaration, currentStyle, DD, DIR, DIV, DL, DT, FIELDSET, FORM, hn, ISINDEX, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, runtimeStyle, style, TABLE, TBODY, TFOOT, TH, THEAD, TR, UL, XMP, CSSCurrentStyleDeclaration Constructor, CSSRuleStyleDeclaration Constructor, CSSStyleDeclaration Constructor
See Also