I'm Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with HTML, CSS and SVG. To receive more information, including news, updates, and tips, you should follow me on Twitter or add me on Google+.

my books

Pro CSS3 Animation book coverPro CSS3 Animation, Apress, 2013

my other blogs

Massive Head CanonMassive Head Canon: Intelligent discussion of movies, books, games, and technology.

my projects

The New DefaultsThe New Defaults — A Sass color keyword system for designers.

CSSslidyCSSslidy — an auto-generated #RWD image slider. 3.8K of JS, no JQuery.

Create Quality Print Versions of Web Pages With CSS3 Filters

Gain accurate print copies, reduce user frustration, and save toner cartridges.

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.

This site helps millions of visitors while remaining ad-free. For less than the price of a cup of coffee, you can help pay for bandwidth and server costs while encouraging further articles.