...

View Full Version : code to achieve page breaks when printing ?



guermantes
05-15-2009, 12:23 PM
Hi,

The visitors of my site to 99% live in countries where A4 is the standard paper size. Can I code my webpages so that they print nicely on A4, so that paragraphs are not broken up between printed pages?

A workaround would be to offer a printable PDF, but I would like to avoid that if possible,

Thanks!

/g

Rowsdower!
05-15-2009, 12:49 PM
Hi,

The visitors of my site to 99% live in countries where A4 is the standard paper size. Can I code my webpages so that they print nicely on A4, so that paragraphs are not broken up between printed pages?

A workaround would be to offer a printable PDF, but I would like to avoid that if possible,

Thanks!

/g

If you want to set page breaks (I don't think you can specify paper size to use with breaks, but you can just set general page breaks) then check this out:
http://www.w3schools.com/css/css_ref_print.asp
and this one in particular:
http://www.w3schools.com/css/pr_print_pagebb.asp

Here is one example:
p
{
page-break-before: always;
}


If you leave that as "always" then it will page break in the printing even if not necessary, but if you leave it as "auto" then it should allow a page break right before the element when needed (in other words, I believe it should work with any page size if it is ever needed to start a paragraph on a new page if it would wrap to a second one).

Let me know if this is what you're looking for.

guermantes
05-15-2009, 01:43 PM
Thanks a lot!

That seems to be exactly what I am after.

Cheers!

/g



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum