The Style pageBreakAfter property is used for setting or returning the page-break behavior after an element in printing or print preview.
The Style pageBreakAfter property does not affect the absolutely positioned elements.
To get the property:
To set the property:
object.style.pageBreakAfter = "auto|always|avoid|emptystring|left| right|initial|inherit"
- auto : It is used to insert a page break after the element if necessary.
- always : It is used to insert a page break after before the element.
- avoid : It is used to avoid a page after before an element.
- emptystring : Page break is not inserted after the element.
- left : It is used to insert one or two page breaks after the element, so the next page is considered a left page.
- right : It is used to insert one or two page breaks after the element, so the next page is considered a right page.
- initial : It is used to set this property to its default value.
- inherit : It is used to inherit this property from its parent element.
Below program illustrates the Style pageBreakAfter property :
Example 1: Setting a page break after the <p> element with id=”footer”
- Before Clicking the button:
- After clicking the button:
Note: In order to see the output, please save the code in HTML file and run it on your browser. The output will be seen when you will see the PRINT PREVIEW of that file.
Supported Browsers: The browser supported by HTML DOM | Style pageBreakAfter Property are listed below:
- Google Chrome
- Internet Explorer
- Apple Safari