Page-Break-* Doesn't Work on Google Chrome

page-break-after does not work in Chrome

It is a hack, but Chrome doesn't support page-breaks very well. So try to use this instead:

<body>
<main role="main">
<section class="tabs">
<div class="tabbed-content">
<div class="break-after">Page 1</div>
<div class="break-before">Page 2</div>
</div>
</section>
</main>
</body>

And add this to your css:

html, body, .main, .tabs, .tabbed-content { float: none; }

.break-after {
display: block;
page-break-after: always;
position: relative;
}

.break-before {
display: block;
page-break-before: always;
position: relative;
}

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.

page-break/webkit-region-break not working in chrome anymore?

Make sure the element with page-break-after: always; is a block element. Another selector might be changing it to inline-block or something else which would prevent the break from being applied.

Also make sure the element is not within a floated element. Thanks RoadBump.

CSS Page-Break Not Working in all Browsers

Parent elements can not have float on them.

Setting float:none on all parent elements makes page-break-before:always work correctly.

Other things that can break page-break are:

  • using page-break inside tables
  • floating elements
  • inline-block elements
  • block elements with borders


Related Topics



Leave a reply



Submit