CSS | page-break-after Property
The page-break-after property in CSS is used to add a page-break after the stated element.
Similarly, page-break-before, page-break-after, and page-break-inside all three properties are instrumental in determining and hence defining how the resultant document would be when printed.
Note: The page-break-after property cannot be used on absolutely positioned elements or an empty <div> element.
Syntax:
page-break-after: auto|always|avoid|left|right|initial|inherit;
Property values:
- auto : This value refers to automatic page-break.
page-break-after:auto;
Example:
<!DOCTYPE html><html><head><title>page-break-after: auto</title></head><body><pstyle="page-break-after:auto;">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p>Text credits: https://en.wikipedia.org/wiki/Paragraph</body></html>chevron_rightfilter_none - always: On using this value, page break is inserted after specified element box always.
page-break-after:always;
Example:
<!DOCTYPE html><html><head><title>page-break-after: always</title></head><body><pstyle="page-break-after:always;">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p><pstyle="page-break-after:always;">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p>Text credits : https://en.wikipedia.org/wiki/Paragraph</body></html>chevron_rightfilter_none - avoid: On using this value, page break is avoided whenever possible.
page-break-after:avoid;
Example:
<!DOCTYPE html><html><head><title>page-break-after: avoid</title></head><body><pstyle="page-break-after:avoid;">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p><p>The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p>Text credits :https://en.wikipedia.org/wiki/Paragraph</body></html>chevron_rightfilter_none - left: On using this value, page break is inserted such that next page is depicted as the left page.
page-break-after:left;
Example:
<!DOCTYPE html><html><head><title>page-break-after: left</title></head><body><pstyle="page-break-after:left;">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p><p>The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p>Text credits :https://en.wikipedia.org/wiki/Paragraph</body></html>chevron_rightfilter_none - right: On using this value page break is inserted such that next page is depicted as the left page.
page-break-after:right;
Example:
<!DOCTYPE html><html><head><title>page-break-after: right</title></head><body><pstyle="page-break-after:right;">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p><p>The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p>Text credits :https://en.wikipedia.org/wiki/Paragraph</body></html>chevron_rightfilter_none - initial : If this value is used then the property will be set to default.
page-break-after:initial;
Example:
<!DOCTYPE html><html><head><title>page-break-after: initial</title></head><body><pstyle="page-break-after:initial;">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p><p>The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p>Text credits :https://en.wikipedia.org/wiki/Paragraph</body></html>chevron_rightfilter_none - inherit : Property is inherited from parent element
page-break-after:inherit;
Example:
<!DOCTYPE html><html><head><title>css_page_break_after</title><style>p {page-break-after:always;}div{page-break-after:default;}#c1{page-break-after:left;}#c2{page-break-after:inherit;}</style></head><body><p>The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p><div><pid="c2">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</div><pid="c1">The oldest classical Greek and Latinwriting had little or no space betweenwords and could be written in boustrophedon(alternating directions). Over time, textdirection (left to right) became standardized,and word dividers and terminal punctuationbecame common. The first way to divide sentencesinto groups was the original paragraphos,similar to an underscore at the beginning ofthe new group.[2] The Greek paragraphosevolved into the pilcrow, which in Englishmanuscripts in the Middle Ages can be seeninserted inline between sentences. The hederaleaf (e.g. ?) has also been used in the same way.</p>Text credits :https://en.wikipedia.org/wiki/Paragraph</body></html>chevron_rightfilter_none
Note: The outcome of page-break-after property can be best viewed by opting for print preview of the webpage of the given HTML code. Create a similar code on your text editor like notepad++ and opt for print preview of the webpage created. Do try it for a better understanding.
Supported Browsers: The browsers supported by are listed below:
- Goolge Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- HTML DOM | Style pageBreakAfter Property
- CSS | transition-property Property
- CSS | all Property
- CSS | top Property
- CSS | right Property
- HTML | DOM name Property
- CSS | height Property
- CSS | border-right Property
- CSS | order property
- CSS | animation-name Property
- CSS | grid-row Property
- CSS | padding-right Property
- CSS | columns Property
- CSS | The object-fit Property
- CSS | direction 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.



