HTML Printing: Use a Style Sheet to Force a Page Break

Designing web pages for printing can be difficult. This tutorial explains how to force a printer to insert a page break.


Designing web pages that can be easily printed can be very, very difficult. PDFs are perfect, but they are expensive to do dynamically. Here is a cheap way to insert a page break into a page.

Place the following code in the HEAD of the html:

<STYLE TYPE='text/css'>
P.pagebreakhere {page-break-before: always}
</STYLE>

Then place the following code in the BODY of the html where you want the pagebreak:

<P CLASS="pagebreakhere">

The Conversation

Follow the reactions below and share your own thoughts.

5 Responses to “HTML Printing: Use a Style Sheet to Force a Page Break”

  1. February 24, 2009 at 3:26 pm, JO'C said:

    this does not work.

    Reply

  2. January 30, 2010 at 7:11 pm, Anonymous said:

    Even simpler:< style=”page-break-before: always” />

    Reply

  3. January 30, 2010 at 7:16 pm, Anonymous said:

    Even simpler:

    <br style=”page-break-before: always” />

    Reply

  4. December 31, 2010 at 4:22 am, Bruce said:

    Thanks to the author as well as dkgibson for this useful tip.

    Reply

  5. March 28, 2011 at 10:12 pm, banners printing said:

    Its not working. generate unexceptional error handling.

    Reply

Leave a Reply

You may also like-

Keynote: Print Slides in ColumnsKeynote: Print Slides in ColumnsPrinting nine slides per printed page is a common way of making handouts from powerpoint or keynote presentations. In Keynote, finding this printing option ... Notepad: Disable the Printing of Page Header and FooterNotepad: Disable the Printing of Page Header and FooterI use Microsoft Notepad for all sorts of tasks from quick edits to web pages to viewing text files to making grocery lists. One ...