CSS Pagebreak example

Shows how to add a pagebreak command to a webpage by using CSS.

Look at the print preview of the example page.

<style type="text/css">
/* this is the important part (should be used in HTML head): */
.pagebreak {
    page-break-after: always;
<h1>First page</h1>
<p>Some text</p>
<br class="pagebreak" />
<h1>Second page</h1>
<p>Some more text</p>
<br class="pagebreak" />
<h1>Third page</h1>
<p>And again some text</p>
Snippet Details

Sorry folks, comments have been deactivated for now due to the large amount of spam.

Please try to post your questions or problems on a related programming board, a suitable mailing list, a programming chat-room,
or use a QA website like stackoverflow because I'm usually too busy to answer any mails related
to my code snippets. Therefore please just mail me if you found a serious bug... Thank you!

Older comments: