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

Contributor Icon Contributed by MickeyMouse  
Tag Icon Tagged: HTTP  

Designing web pages for printing can be difficult. Here’s 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 expensive to do dynamically. Anyway, 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">

 

5 Comments -


  1. JO'C said on February 24, 2009

    this does not work.

  2. Anonymous said on January 30, 2010

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

  3. Anonymous said on January 30, 2010

    Even simpler:

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

  4. Bruce said on December 31, 2010

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

  5. banners printing said on March 28, 2011

    Its not working. generate unexceptional error handling.

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -