• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2049
  • Last Modified:

page-break-inside, why not working?

I have a table where I don't want the contents of a cell to break across pages. I tried the following code but still the cells break:

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


Should this work in IE6? Is there an alternative (except those where I need to count the pixels for each line of text, etc.)
0
elvin226
Asked:
elvin226
  • 4
  • 4
1 Solution
 
avnerCommented:
Use this approach :
<td norwap="true">


Page-break-inside, as far as the MSDN documenation, is not yet supported.
0
 
gator4lifeCommented:
The nowrap attribute is not meant to format content for printed media; it is only meant to format content on the screen.

Even though the page-break-inside attribute is not yet supported in Internet Explorer, the page-break-before and the page-break-after attributes are.  The only value for this attribute that will currently force the page break for these two attributes is the 'always' value.

So, for your example, you can do this:

<table>
    <tr>
        <td style="page-break-before: always;">
            Some text...
        </td>
    </tr>
    <tr>
        <td style="page-break-before: always;">
            Some text...
        </td>
    </tr>
</table>

which will always force a page break before both of the cells, or you can do this:

<table>
    <tr>
        <td style="page-break-after: always;">
            Some text...
        </td>
    </tr>
    <tr>
        <td style="page-break-after: always;">
            Some text...
        </td>
    </tr>
</table>

which will always force a page break after both of the cells.

gator4life
(chomp, chomp)
0
 
avnerCommented:
I don't think elvin226 refers to any printing issue...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
gator4lifeCommented:
The only reason that the page-break-inside, page-break-before, or page-break-after CSS attributes would be used is for the layout of web content for printed media, so I would assume that this has to do with content for printed media.  Also, they state "...I don't want the contents of a cell to break across pages."  Last time I checked, web content did not inherently have pages, but printed media sure does...

gator4life
(chomp, chomp)
0
 
avnerCommented:
You got a point there.. I missed that part..
0
 
gator4lifeCommented:
Then again, if they never write back, we'll never know! :-)

gator4life
(chomp, chomp)
0
 
elvin226Author Commented:
gator4life is correct. i asked this question because of printing issue. but i have no intention to use the page-break-before/after because it will use a lot of paper while in reality, several cells may fit 1 page. what i don't want to happen are cells breaking across pages.
0
 
avnerCommented:
Then, As I wrote , since page-break-inside is not yet supported you can not solve this problem using HTML and CSS.
If the ouput of the printing is very important, Go with PDF, any other solution is not 100% realiable.
0
 
gator4lifeCommented:
avner is correct elvin.  If you can't use what the browsers currently support through the CSS properties available, then your best bet is to convert the content into a downloadable and/or printable format, such as a .pdf, that you can link to on your website.  If you haven't noticed, this is the current status quo on much of the internet, since the CSS @media rules for printing are still too young to provide a lot of benefit.

gator4life
(chomp, chomp)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now