D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] CSS hacks. page-breaks and orphans



On Saturday 05 Jul 2003 12:45 am, Tony Atkin wrote:
> On Saturday 05 July 2003 12:18 am, Jonathan Melhuish wrote:
> > Could you design some clever CSS that automatically calculates when the
> > last page of your printout is going to consist of the header, the footer
> > and a couple of words of text?  I'd hate to think how many sheets of
> > paper get wasted like that every year...
>
> I always thought that this was one of those cruel twists of fate, like
> toast always landing butter side down. It's real, it's happening and it's
> out there.  Somebody should produce a dossier.

Not true. All you need to do is fix the toast, butter side up, to your cat's 
back, drop the cat and you'll have perpetual motion and never work again.
:-)

Anyhow, CSS can help with page breaks. I'm working on it, but basically you 
can add a CSS rule to any block level tag (P,DIV,UL,LI,etc) that dictates how 
page breaks are handled. 
http://www.w3.org/TR/REC-CSS2/page.html#page-break-props
page-break-inside:avoid

There are also rules for page-break-above or below.

In addition, there are rules about widows and orphans.

What Jon described is an orphan. The CSS can set a rule that orphans are only 
allowed if there are, say 10 lines in the orphaned section. Any less and the 
entire section is moved across the page-break. Widows are lines left hanging 
on the previous page with the rest of the paragraph on the next page. CSS can 
set that widows are only allowed if, say 5 lines are in the widow section.

None of these settings make any sense if the CSS media rule is set to screen 
so I use the @media rule to adjust the settings just for print. (Take a look 
at lug.css and lug2.css in your browser cache or in the top level directory 
at www.dclug.org.uk/ for examples).

There are also settings for page size so that your browser shouldn't default 
to American sizes.

There are even rules to set different margins for odd and even page numbers to 
make double-sided printing easier for booklets etc.

-- 

Neil Williams
=============
http://www.codehelp.co.uk
http://www.dclug.org.uk

http://www.wewantbroadband.co.uk/

Attachment: pgp00022.pgp
Description: signature


Lynx friendly