I cannot get this CSS to work in Chrome and 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 and Firefox insert a page break after an element <h1>when printing.
Only IE saves h1 + p together.
HTML is generated ( https://github.com/chjj/marked ), so I would prefer to solve this with CSS, if possible.
source
share