Solved

HTML page breaks

Posted on 2004-09-29
7
916 Views
Last Modified: 2008-03-17
Is there a way to put something like page breaks into a table in HTML so that when the user prints the page, rows are not split between 2 pages?  I am not at all familiar with JavaScript but am willing to learn it if necessary.
0
Comment
Question by:LBugbee
7 Comments
 
LVL 5

Expert Comment

by:php-webdesign
Comment Utility
0
 
LVL 1

Accepted Solution

by:
bame earned 250 total points
Comment Utility
Instead of telling the browser where to break, you can tell the browser NOT to put page breaks in rows by setting the "page-break-inside" CSS property to "avoid".

<table>
<tr style="page-break-inside: avoid">
<td>...</td>
</tr>
</table>

If you really do want to force page breaks, take a look at page-break-after and page-break-before.

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

Note: Mozilla-based browsers (like Netscape) don't support this yet. See https://bugzilla.mozilla.org/show_bug.cgi?id=132035
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
If you are printing a table, it is very like to get screwed up will some setting no matter what you do.  If there are nested tables then the chances of success are somewhere a little less than zero.  If the printing is critical, then use a pdf or other print friend file type; or develop a printer friendly stylesheet that does a rendering without the tables.

Cd&
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Expert Comment

by:minichicken
Comment Utility
This is what I use to do page breaks for printing pages
use style="page-break-before:always" in your table tag

Example:

<table style="page-break-before:always" width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>

j311y :)
0
 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
As to what minichicken says, better assign that style to your tr's because ;-)

<style type="text/css">
 table.unbreakablerows tr {page-break-before:always;}
</style>

<table class="unbreakablerows">
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
<tr><td>Data<br/>Data<br/>Data<br/>Data<br/>Data<br/>Data</td></tr>
</table>

-r-
0
 

Author Comment

by:LBugbee
Comment Utility
Bame's suggested "page-break-inside: avoid" sounds like what I'm looking for but it didn't work. (IE6) I don't want a new page everytime I start this row, only if it's going to overflow to the next page.
0
 
LVL 49

Expert Comment

by:Roonaan
Comment Utility
Use page-break-inside:avoid;

or page-break-before:auto;

See also: http://www.w3schools.com/css/css_ref_print.asp
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now