2

I have an table with nested tables in. When I am printing this page, the cells gets split on page break.

Is there any chance that I can control that it should jump onto the next page instead of splitting the middle?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
janhartmann
  • 14,713
  • 15
  • 82
  • 138
  • For webkit based browsers see http://stackoverflow.com/questions/1539876/controlling-css-page-breaks-when-printing-in-webkit. – jonathan Oct 19 '12 at 13:54

2 Answers2

2

I have used the following method to keep the contents of a row together on one page:

<tr style="page-break-inside: avoid">

Unfortunately browser support is limited. Works fine in Internet Explorer 9, but not in Chrome 22 or Firefox 15.

benrwb
  • 853
  • 7
  • 15
  • 1
    As of 2016, **this should now work in recent browsers.** Mozilla Developer Network claims "basic support" starting with Chrome 1.0, Firefox 19, IE 8.0, Opera 7.0, and Safari 1.3. (https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-inside) It works fine for me in recent Firefox. – ASL Sep 26 '16 at 16:00
1

You can have a look at the page-break-before css property. For example you can set it to auto on each of your cells.

Bur I can't guarantee this will work, each navigator prints a little differently. Firefox is known to have problems printing big tables (more than a page) for example.

krtek
  • 26,334
  • 5
  • 56
  • 84
  • But the default value is 'auto'? – janhartmann Feb 28 '11 at 08:06
  • Like I said, browsers tends to do strange things when printing. I once resolved a similar problem with page-break-before: auto. Maybe with a piece of your html code it will be easier to help. – krtek Feb 28 '11 at 08:17