Reputation: 6060
I'm trying to find out if there is a way to ensure that certain elements on a page that I'm returning doesn't get split while printing ie. <div>
or <fieldset>
. I am aware of doing a css for printing, but am not sure if there is a property that I can assign to an element that would ensure this.
Upvotes: 1
Views: 1021
Reputation: 201588
The CSS declaration for the purpose is page-break-inside: avoid
, but browser support to it is still rather limited. Note that various CSS support summary documents on the web may paint too optimistic a picture on this. The real support seems to about Opera and IE 8+ (standards mode), with limitations.
The page-break-before: always
declaration works much wider, and by forcing a page break before an element, you more or less ensure that line breaks don’t appear inside it if they can be avoided. But this is rather questionable approach, as you could well force many page breaks that are not needed and may cause very poor results (e.g., a page with one line only—due to a natural page break before it and a forced page break after it).
Upvotes: 3