[WEB4LIB] web pages not printing correctly

Eli Naeher enaeher at ec.rr.com
Wed Mar 30 09:08:30 EST 2005


On Wed, 30 Mar 2005 03:48:31 -0800 (PST)
John Fitzgibbon <jfitzgibbon at Galwaylibrary.ie> wrote:

> Hi,
> 
> I have a number of web pages that will not print correctly. I have
> divided each page into two divs. One div is a side bar and is named
> sidebar and the other is the main div to its right and is named div.
> When I print and when I print-preview the content, the main div appears
> extremely narrow.

CSS styles can cause lots of trouble with printing. I've had lots of trouble with fixed-width divs where the width is specified in pixels.

You can set print CSS styles that override the CSS used for your web page, which is very handy. You can even use CSS print styles to suppress bits of the page (i.e. navigation bars) that you don't want to print at all. There's an excellent tutorial at http://www.alistapart.com/articles/goingtoprint/ which details how to set up a seperate print stylesheet. A somewhat simpler (IMHO) method is something like this:

div.whatever { width: 700px; }

@media print {

	div.whatever { width: auto; }

}

This doesn't require you to add new links to print stylesheets to all your HTML -- you can stick the @media directive at the end of your existing CSS file.

--Eli Naeher
  Lower Cape Fear Historical Society



More information about the Web4lib mailing list