Google Chrome Printing Page Breaks Google Chrome Printing Page Breaks google-chrome google-chrome

Google Chrome Printing Page Breaks


I've used the following approach successfully in all major browsers including Chrome:

<!DOCTYPE html><html>  <head>    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />    <title>Paginated HTML</title>    <style type="text/css" media="print">      div.page      {        page-break-after: always;        page-break-inside: avoid;      }    </style>  </head>  <body>    <div class="page">      <h1>This is Page 1</h1>    </div>    <div class="page">      <h1>This is Page 2</h1>    </div>    <div class="page">      <h1>This is Page 3</h1>    </div>  </body></html>

This is a simplified example. In the real code, each page div contains many more elements.


Actually one detail is missing from the answer that is selected as accepted (from Phil Ross)....

it DOES work in Chrome, and the solution is really silly!!

Both the parent and the element onto which you want to control page-breaking must be declared as:

position: relative

check out this fiddle:http://jsfiddle.net/petersphilo/QCvA5/5/show/

This is true for:

page-break-beforepage-break-afterpage-break-inside

However, controlling page-break-inside in Safari does not work (in 5.1.7, at least)

i hope this helps!!!

PS: The question below brought up that fact that recent versions of Chrome no longer respect this, even with the position: relative; trick.However, they do seem to respect:

-webkit-region-break-inside: avoid;

see this fiddle:http://jsfiddle.net/petersphilo/QCvA5/23/show

so i guess we have to add that now...

Hope this helps!


I just wanted to note here that Chrome also ignores page-break-* css settings in divs that have been floated.

I suspect there is a sound justification for this somewhere in the css spec, but I figured noting it might help someone someday ;-)

Just another note: IE7 can't acknowledge page break settings without an explicit height on the previous block element:

http://social.msdn.microsoft.com/forums/en-US/iewebdevelopment/thread/fe523ec6-2f01-41df-a31d-9ba93f21787b/