3

I am unable to get this CSS to work in Chrome & Firefox.

p { page-break-inside: avoid; }
h1 { page-break-after: avoid; }

Html:

<h1>FOO</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<h1>FOO</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
[..]

Chrome & Firefox will insert a page break after the <h1> element when printing.

Only IE keeps h1+p together.

The HTML is generated (by https://github.com/chjj/marked) so I'd rather like to solve this by CSS if possible.

laktak
  • 57,064
  • 17
  • 134
  • 164

1 Answers1

0

Try using -webkit-break-after: avoid; -webkit-break-inside: avoid;

Muhammad
  • 193
  • 1
  • 7