Adding Pagebreaks in HTML documents

While printing long HTML documents, we may need to add pagebreaks to make sure our contents get printed on a new page.

Say for example, we need to print a long list of invoices read from database in such a way that a page break is required between each invoice so that only one invoice gets printed per page.

Here's a solution to it using CSS:

Then, in the HTML page, we should assign this class 'pagebreak' to the div that should be printed per page.

 

NOTE: CSS print-specific properties require browser compatibility and may not work across several browsers. However, I have tested it on Opera and Internet Explorer and it works fine in these browsers.