HTML DOM | Style pageBreakAfter Property
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.
Syntax :
object.style.pageBreakAfter
Property Values :
object.style.pageBreakAfter = “auto|always|avoid|emptystring|left|right|initial|inherit”
Values Description:
- 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”
<!DOCTYPE html> <html> <head> <title>Style pageBreakAfter Property in HTML</title> <style> h1 { color: green; } h2 { font-family: Impact; } body { text-align: center; } </style> </head> <body> <h1>GeeksforGeeks</h1> <h2>Style pageBreakAfter Property</h2> <br> <p id="myfooter">Geeksforgeeks is a portal for geeks.</p> <p>For setting page break after footer paragraph, double click the "Set Page Break" button: </p> <br> <button ondblclick="pagebreak()">Set Page Break</button> <script> function pagebreak() { document.getElementById("myfooter") .style.pageBreakAfter = "always"; } </script> </body> </html> |
Output:
- 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 Web Browsers
- Opera
- Internet Explorer
- Google Chrome
- Firefox
- Apple Safari
Recommended Posts:
- HTML | DOM Style top Property
- HTML | DOM Style right Property
- HTML | DOM Style fontSize Property
- HTML | DOM Style counterReset Property
- HTML | DOM Style marginLeft Property
- HTML | DOM Style letterSpacing Property
- HTML | DOM Style left Property
- HTML | DOM Style minHeight Property
- HTML | DOM Style font Property
- HTML | DOM Style maxWidth Property
- HTML | DOM Style justifyContent Property
- HTML | DOM Style fontFamily Property
- HTML | DOM Style listStylePosition Property
- HTML | DOM Style borderLeftWidth Property
- HTML | DOM Style captionSide Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



