Solved

HTML page breaks

Posted on 2004-09-29
7
923 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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

623 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