Skip to content

Print Stylesheet

You'll write about 20 lines of print CSS so one page of your site comes out clean on a single sheet of paper, then print it for real.

About

Most sites print as a mess, with the navigation, the footer and half an image straddling a page break. A print stylesheet fixes that in about 20 lines. Pick a page worth holding in your hand, like a recipe, a reading list, your resume or a packing list, and print it. If it comes out well, it's going on the fridge. If you don't own a printer, a library or a copy shop will print one sheet for a few cents.

At a glance

Per requirement
15 XP
Completion bonus
75 XP
Requirements
5
Takes
One evening
Skill level
Beginner (done it a few times)
Cost
Cheap (under $10)
Supplies
You need some
Where
At home
Other people
On your own

Requirements

  1. 1
    Pick one page people might want on paper. A resume, a recipe, a checklist or a schedule all work, as long as it's something useful away from a screen. Take a screenshot of the page as it prints today, using the browser's print preview. Photo
  2. 2
    Add a print media query that hides the chrome. Start with @media print { nav, footer, .no-print { display: none } }. Set the body to black text on white at 11 to 12pt, and widen the content to fill the page. Take a screenshot of the rules. Photo
  3. 3
    Show where links go and stop bad page breaks. Use a::after { content: ' (' attr(href) ')' } so external links print with their address. Add break-inside: avoid to headings, images and list items so they don't get cut in half. Take a screenshot of the print preview showing a link with its URL. Photo
  4. 4
    Print it on real paper. A PDF doesn't count here. Use an actual printer and one sheet, and if you don't own one, a library or a copy shop charges a few cents. Take a photo of the printed page. Photo
  5. 5
    Hand it to someone who would use it. A friend who asked for the recipe, your own fridge, or a manager with your resume all count. Take a photo of the page in its new home. Photo