Printer-Friendly Alternate Stylesheets

By Deane Barker on November 18, 2002

Here’s something handy that my buddy Rob mentioned to me months ago, but that I just got around to trying:

I added a new stylesheet LINK tag to the index pages, but with the “media=’print’” argument. Thus, this stylesheet will be used only when the browser is rendering the page to be printed. In this sheet, I added “display: none;” to the “#LeftColumn” and “#RightColumn” identifiers. Thus, when the page is printed printed, only the center column prints — the two navigation columns are suppressed (since they don’t contain any appreciable content anyway, and there’s not much reason to print them). Go to Print Preview and see.

And there’s another insanely handy thing about it. Using the CSS Generated Content (only in Mozilla / Netscape and Opera), I can print the value of the HREF attribute in parentheses after every hyperlink. This is handy because, in print, links are meaningless — you have no way of knowing where they go. But now you can have a printed document with the URLs of all hyperlinks listed, while a user viewing it on the screen sees nothing out of the ordinary.

Gadgetopia