Style pageBreakAfterProperty
Style Object
Definition and Usage
The pageBreakAfter property sets or returns the page-break behavior after an element (for printing or print preview).
Note:The pageBreakAfter property does not affect absolutely positioned elements.
Syntax
Set the pageBreakAfter property:
Object.style.pageBreakAfter="auto|always|avoid|emptystring|left|right|inherit"
Return the pageBreakAfter property:
Object.style.pageBreakAfter
| Value | Description |
|---|---|
| auto | Default. Inserts a page break after the element if necessary. |
| always | Always insert a page break after the element. |
| avoid | Avoid inserting a page break after the element. |
| "" (empty string) | Do not insert a page break after the element. |
| left | Insert one or two page breaks after the element, until a blank left page is reached. |
| right | Insert one or two page breaks after the element, until a blank right page is reached. |
| inherit | The value of the pageBreakAfter property is inherited from the parent element. |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the pageBreakAfter property.
Note:IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".
Example
Example
Always set a page break after each <p> element with id="footer":
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function setPageBreak(){
document.getElementById("footer").style.pageBreakAfter="always";
}
</script>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<p id="footer">This is the footer paragraph</p>
<button type="button" onclick="setPageBreak()">Set Page Break After Bottom Paragraph</button>
<p>Click the button above to see the changes in printing or print preview.</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function setPageBreak(){
document.getElementById("footer").style.pageBreakAfter="always";
}
</script>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<p id="footer">This is the footer paragraph</p>
<button type="button" onclick="setPageBreak()">Set Page Break After Bottom Paragraph</button>
<p>Click the button above to see the changes in printing or print preview.</p>
</body>
</html>
Try it Yourself »
Style Object Other Extensions