Example
Always set a page break before each <p> element with id="footer":
document.getElementById("footer").style.pageBreakBefore = "always";
Try it Yourself »
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. The page break is only visible in a print preview or when printing.
Browser Support
The pageBreakBefore property is supported in all major browsers.
Syntax
Return the pageBreakBefore property:
object.style.pageBreakBefore
Set the pageBreakBefore property:
object.style.pageBreakBefore="auto|always|avoid|emptystring|left|right|initial|inherit"
Property Values
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 |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | auto |
---|---|
Return Value: | A String, representing the page-break behavior before an element when printing |
CSS Version | CSS2 |
Related Pages
CSS reference: page-break-before property
< Style Object