Chapter 10. Print

Introduction

To create a printer-friendly version of a web page, traditionally web developers would either have to manually convert the web page content to a separate stripped-down page design or use a script to dynamically generate a separate page design.

With CSS, however, you can automatically apply a new style sheet to documents when they are printed, thereby eliminating the time and server resources needed to create a printer-friendly page.

Support for print-media CSS is fairly commonplace these days. Currently, the browsers that support this aspect of the technology include Firefox, Internet Explorer 4+ for Windows, Internet Explorer 4.5+ for Macintosh, Navigator 6+, Safari, and Opera.

Print-only properties are associated with CSS. However, these properties have limited support among the browsers on the market; Opera 5 and 7 are the only browsers that support more than two of these kinds of properties (15 printing properties out of the 16 in the specification).

Because of this reality and because the purpose of this book is to focus on the practical, cross-browser nature of CSS, the recipes in this chapter are geared to styling the contents of the page rather than dealing with the theory of CSS printing properties. For more information on CSS printing properties, see Cascading Style Sheets: The Definitive Guide, by Eric A. Meyer (O’Reilly Media).

This chapter teaches the basics of how to tell the browser which style sheet to use when sending a document to print. ...

Get CSS Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.