Solved

HTML page breaks

Posted on 2004-09-29
7
920 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 5

Expert Comment

by:php-webdesign
ID: 12178948
0
 
LVL 1

Accepted Solution

by:
bame earned 250 total points
ID: 12180143
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
ID: 12182414
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:minichicken
ID: 12182448
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
ID: 12184320
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
ID: 12184608
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
ID: 12184752
Use page-break-inside:avoid;

or page-break-before:auto;

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

751 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