1 out of 5 rated this helpful - Rate this topic

page-break-before Attribute | pageBreakBefore Property

Gets or sets a string indicating whether a page break occurs before the object.

Syntax

CSS { page-break-before : sBreak }
Scripting [ sBreak = ] object.style.pageBreakBefore

Possible Values

sBreak String that specifies or receives one of the following values.
always
Always insert a page break before the object.
auto
Default. Neither force nor forbid a page break before the object.
avoid
Windows Internet Explorer 8. Forbid a page break before 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 the value of this property and the pageBreakAfter property of 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-before attribute and the pageBreakBefore property to start printing on a new page.

This example uses the H3 element as a selector in an embedded style sheet to break the page before all H3 headings.


<html>

<head>
<style type="text/css">
h3 {
	page-break-before: always;
}
</style>
</head>

<body>

<p>
:
</p>
<h3>Start New Section on New Page</h3>

</body>

</html>

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/page-break-before.htm

This example uses a button to turn off the page break before the object that has an ID value of oPrgrph. When the page is printed or previewed, a page break occurs before the first paragraph unless the user clicks the button.


<html>

<head>
<script type="text/javascript">
function offBreak()
{
    oPrgrph.style.pageBreakBefore="";
}
</script>
</head>

<body>

<button onclick="offBreak()">Turn Off Break</button>
<p id="oPrgrph" style="page-break-before: always">
: 
</p>

</body>

</html>

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/pagebreakBefore.htm

Standards Information

This property is defined in Cascading Style Sheets (CSS), Level 2 (CSS2).

Applies To

ADDRESS, BLOCKQUOTE, BODY, CAPTION, CENTER, CSSStyleDeclaration, currentStyle, DD, DIV, DL, DT, FIELDSET, FORM, hn, ISINDEX, LI, LISTING, MENU, OL, P, PLAINTEXT, PRE, runtimeStyle, style, TABLE, TBODY, TD, TFOOT, TH, THEAD, TR, UL, XMP, CSSCurrentStyleDeclaration Constructor, CSSRuleStyleDeclaration Constructor, CSSStyleDeclaration Constructor

See Also

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ