W3Schools.com

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.


Example

Example

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

<html>
<head>
<script type="text/javascript">
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
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE