Optimizing Your Website Content For Print Using CSS

css, html, javascript

Now that you've optimized your website structure for print and you've isolated the content worth part of your page, you can move forward with optimizing your page content for print. Remember that we included our "main" style sheet with the media "all," meaning that those properties will carry over into print. Essentially, we are readjusting our settings for print. Readability is our central goal.

Adjust Your Heading Tag Properties
If you've optimized your website for search engine optimization you're probably using your "h" tags to the fullest. Realize that you wont have color options when your site is in printed mode -- few people print in color. I recommend limiting your heading to <h1> through <h3>. After three headings, the printed result will lose some organization. Padding, margin, border, and font-size will be important. Make sure your <h1> tag is large enough to make it known that it is the subject of the printed piece. For the <h2> tag, I recommend using a bottom-border property to establish the tag as the second heading. The <h3> will be the same size or slightly larger than the paragraph text. All tags will be in bold. To make things easier, I recommend using margin and setting the padding to 0; the two properties control the same function for printing and it will be easier to just use one. I recommend very little margin below the heading with exception to the <h1> tag. I use the following:

copyh1,h2,h3  { font-weight:bold; }
h1    { font-size:24px; }
h2    { font-size:16px; border-bottom:1px solid #ccc; padding:0 0 2px 0; margin:0 0 5px 0; }
h3    { font-size:13px; margin:0 0 2px 0; }

Adjust Your Paragraph Tag Properties
Most people don't do anything too drastic with their paragraph tags but there are some properties you can optimize. The line-height, padding, and margin will be the most important properties to address. I also recommend setting the bottom margin of the paragraph to a value more than the line-height. Lastly, adjust the font-size to a reasonable ratio to your headers and use a standard font-family if you aren't already. I use the following:

copyp    { font-size:11px; font-family:times new roman, serif; margin:0 0 18px 0; }

Format Your Links
Print doesn't allow for fancy formatting of links like we've come to enjoy on the screen, so we can keep these simple by simply adding the necessary text-decoration declaration:

copya    { text-decoration:underline; }

Advanced Link Formatting
I call this advanced for a couple of reasons. First, you're relying on CSS not currently supported by all browsers -- Internet Explorer 6 is your adversary here. The following will be completely ignored by IE6 and lower. Second, some programmers don't like the idea of CSS-generated content. Purists, please skip this section.

Showing the user a link may not be good enough. What if you'd like them to know the URL of the link? Simply add the following to your print stylesheet:

copya:link:after, a:visited:after { content: " (" attr(href) ") "; font-size: 90%; }

Adjust Any Custom Classes
Look through your custom CSS classes to make sure none of your other settings will cause your page to look unorganized.

Your web site is now ready to go to print! Be sure to abuse the "Print Preview" option of each browser to ensure maximum readability.

Labels: