Search w3schools.com:

SHARE THIS PAGE

Style pageBreakBefore Property

Style Object Reference Style Object

Definition and Usage

The pageBreakBefore property sets or returns the page-break behavior before an element (for printing or print preview).

Note: The pageBreakBefore property has no effect on absolutely positioned elements.

Syntax

Set the pageBreakBefore property:

Object.style.pageBreakBefore="auto|always|avoid|emptystring|left|right|inherit"

Return the pageBreakBefore property:

Object.style.pageBreakBefore

Value Description
auto Insert a page break before the element if necessary. This is default
always Always insert a page break before the element
avoid Avoid a page break before the element
"" (empty string) Page break is not inserted before the element
left Insert one or two page breaks before the element, so the next page is considered a left page
right Insert one or two page breaks before the element, so the next page is considered a right page
inherit The value of the pageBreakBefore property is inherited from parent element


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The pageBreakBefore property is supported in all major browsers.

Note: The value "inherit" is not supported in IE7 and earlier. IE8 requires a !DOCTYPE. IE9 supports "inherit".


Example

Example

Always set a page break before each <p> element with id="footer":

<html>
<head>
<script>
function setPageBreak()
{
document.getElementById("footer").style.pageBreakBefore="always";
}
</script>
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p id="footer">This is a footer paragraph.</p>
<button type="button" onclick="setPageBreak()">Set page-break before footer paragraph</button>
<p>Click the button above and see the changes in print or print preview.</p>

</body>
</html>

Try it yourself »


Style Object Reference Style Object

W3Schools Certification

W3Schools' Online Certification

The perfect solution for professionals who need to balance work, family, and career building.

More than 10 000 certificates already issued!

Get Your Certificate »

The HTML Certificate documents your knowledge of HTML.

The HTML5 Certificate documents your knowledge of advanced HTML5.

The CSS Certificate documents your knowledge of advanced CSS.

The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.

The jQuery Certificate documents your knowledge of jQuery.

The XML Certificate documents your knowledge of XML, XML DOM and XSLT.

The ASP Certificate documents your knowledge of ASP, SQL, and ADO.

The PHP Certificate documents your knowledge of PHP and SQL (MySQL).

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]