4 replies [Last post]
Anonymous
Anonymous's picture
Guru
calgary,alberta
calgary,alberta

Is there a way to prevent text in a <TD> or <TH>, or more specifically, the
whole <TR></TR> from spanning page boundries when printing (@media print)?
Using IE6, I tried:

TR, TD, TH {page-break-inside:avoid;}
I don't want to use page-break-after or page-break-before because it seems
like my only options are 'always' and 'auto'. The value 'always' will
create almost a hundred pages in my case. I'd just like to page break if
the current row will span pages.

Thanks
Chris

nexia
nexia's picture
Offline
Regular
Last seen: 16 years 13 weeks ago
Timezone: GMT-5
Joined: 2003-03-22
Posts: 42
Points: 0

Prevent &lt;TD&gt; contents from spanning pages when printin

most css printing gadgets are here:

http://www.w3schools.com/css/css_ref_print.asp

(i think it's the basic things, details can be brought otherways...

nexialism source of all knowledges

cbecker
Offline
newbie
Last seen: 16 years 11 weeks ago
Timezone: GMT-8
Joined: 2003-04-01
Posts: 2
Points: 0

Prevent &lt;TD&gt; contents from spanning pages when printin

Thanks, that's a good resource, but I still don't know how to prevent cell contents from spanning pages. What does the "auto" attribute value do? It seems as if it is the same as not specifying anything for page-break-inside.

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 13 hours 17 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Prevent &lt;TD&gt; contents from spanning pages when printin

page-break-inside is not very well supported.
Auto is the default value, so basically wont make any difference in normal circumstances.
You can use page-break-before in a tr like:

<tr style="page-break-before:always">
or
.pb{page-break-before:always;}
<tr class="pb">

if you know which rows you want to break the page on.

If the content is dynamic, from a database etc you may have to find a way to count the content as its displayed and when it gets close to a page put the class in the next tr.

cbecker
Offline
newbie
Last seen: 16 years 11 weeks ago
Timezone: GMT-8
Joined: 2003-04-01
Posts: 2
Points: 0

Prevent &lt;TD&gt; contents from spanning pages when printin

Thanks for everyone's help. I think I will just code it into my page and wait till browsers support it. No harm till then