Print stylesheets tend to be somewhat neglected by web developers, but their presence is often greatly appreciated by users. I’ve previously discussed several best practices when using @media print stylesheets to control what appears when the user decides to print your pages on a color printer, but have not directly addressed concerns with greyscale printers (i.e. most laser printers).
Why Printer Defaults In Browsers Are Sub-Par
When printing a web page with a dark background and white text, most browsers will reverse the color scheme, at least to some degree. For example, taking this HTML:
And combining it with this CSS:
Produces the following result in the browser:
And the (almost) inverse result when printed:
You can see that the result isn’t completely inverted, appearing somewhat washed out; we’ll correct that in the CSS to come.
The browser does not make any color adjustments when printing images. If the graphic is a solid bitmap, as shown to the right (using a logo by Trevor Sutherland):
The printer will yield the following result:
The printed result looks even worse if the logo is an alpha-masked PNG or SVG file:
Using CSS3 Filters To Improve The Results Of Printed Web Pages
While I’ve focused on using CSS filters for display on screens, you can also use them in the context of a print @media query to reverse the colors of logos and other graphics w printing:
The printed result now looks like this:
For Firefox, we need to use the SVG equivalent filter. I’d suggest saving this code as a separate file (invert.svg), although it could also be included in the code of page HTML page:
Adding the new filter to our CSS:
There is a solution for IE9 developed by Lea Verou, albeit a rather tricky one that uses the invert color option in CSS. The code will cause conflicts with the above CSS, so I’d recommend placing it inside a conditional comment:
Taking the time and effort to concentrate on these kind of details is one of the hallmarks of both great web design and service, and one that will be greatly appreciated by users.
Pro CSS3 Animation, Apress, 2013
Massive Head Canon
The New Defaults
CSSslidy