CSS page-break-after property
This CSS property is used to adjust the page break after the element when printing the document. It inserts a page break after the specified element during printing. We cannot use this property on absolutely positioned elements (position: absolute;) or an empty <div> element that does not generate a box.
This CSS property represents whether or not the page break is allowed after the element's box. Including page-break-after, the CSS properties page-break-before and page-break-inside help us to define the behavior of the document when printed.
The brief description of the values of this CSS property is tabulated as follows.
Let's understand the above values using an example of each.
Example - Using the auto value
The value auto is the default value that inserts a page break automatically when required. In this example, we are using the two <div> elements and a button. The button is responsible to print the page. After clicking on the button, we will see the effect of the value.Test it Now
Example - Using the always value
This value always forces to insert a page break whether it is required or not. We are using a button for printing the page. We have to click that button in order to see the effect.Test it Now
Example - Using the left value
The value left forces to insert one or two page breaks, so that the formatting of the next-page will be as the left page.Test it Now
Example - Using the right value
The value right forces to insert one or two page breaks, so that the formatting of the next-page will be as the right page.Test it Now