I run a small site with printer test pages: color sheets, nozzle check patterns, alignment grids. It sounded like the easiest project I'd ever ship. It's a page you print, so how hard can that be?

Pretty hard, it turns out. Getting a webpage to come out of a printer looking exactly the way you designed it means fighting the browser at almost every step. Here's what I ran into and what actually worked.

1. Browsers strip your backgrounds by default

This was the first surprise. You design a nice CMYK block, hit print, and get a blank page with a few labels on it. Chrome, Firefox and Safari all drop background colors and images when printing to save ink, unless the user ticks "Background graphics" in the print dialog.

You can ask the browser to keep them:

.swatch { -webkit-print-color-adjust: exact; print-color-adjust: exact; } 

It works in current Chromium, Firefox and Safari, but treat it as a request rather than a guarantee. For anything that has to print, like the actual color patches, I stopped relying on background-color and drew them as inline SVG <rect> elements with a fill. The browser treats SVG fills as content, not background, so they print even when background graphics are off.

2. @page is your friend, but only half of it is supported

@page { size: A4; margin: 10mm; } 

size and margin are reliable in Chromium. Firefox has supported size only since fairly recently, so test your target versions. The margin boxes from the spec, like @top-center for running headers, are still patchy, so I don't use them for anything important.

The bigger issue is that users pick their own paper size. Someone in the US prints your A4 layout on Letter and the bottom 18mm gets clipped. I ended up shipping separate A4 and Letter versions instead of one "responsive" print layout, because a test page that changes scale isn't really a test page anymore.

3. Use physical units for anything that gets measured

On screen, px is fine. On paper, an alignment grid needs real millimetres, because people put a ruler on it.

.grid-line { width: 0.25mm; } .calibration-box { width: 100mm; height: 100mm; } 

CSS defines 1in = 96px, and print engines respect that, so mm and in come out accurate as long as the user prints at 100%. That's the catch: "Fit to page" or "Shrink to fit" in the print dialog silently scales everything. I added a 100mm reference box with a visible label so people can check the scale with a ruler before trusting the rest of the page.

4. Hairlines disappear, and thick lines lie

A 1px border looks crisp on a retina screen and then either vanishes or prints as a fuzzy grey line, depending on the printer's resolution and driver. For nozzle check patterns that's a real problem, because the whole point is spotting a missing line.

What worked for me:

  • Line weights of at least 0.25mm for diagonal and step patterns
  • Solid fills rather than borders for the bars
  • Pure process colors (#00FFFF, #FF00FF, #FFFF00, #000000) so each bar maps to one cartridge as closely as the driver allows

One thing worth knowing: the browser sends RGB, and the printer driver converts it to CMYK. You don't control that conversion, so "pure cyan" on screen isn't guaranteed to be cyan-ink-only on paper. Treat the page as a practical diagnostic, not a lab-grade calibration target.

5. Kill the page breaks you didn't ask for

One-page test sheets have to stay on one page. A few properties did most of the work:

@media print { header, nav, footer, .ads, .no-print { display: none !important; } .sheet { break-inside: avoid; page-break-inside: avoid; } html, body { height: auto; overflow: visible; } } 

That overflow: visible line fixed a weird bug where a scrolling container on screen caused only the visible part to print in some browsers.

6. Ship a PDF too

Even after all of this, browser printing is a moving target: different defaults, different dialogs, extensions that inject stuff. So every sheet also has a PDF version built from the same layout. A PDF fixes the page size, keeps the fills, and sidesteps the background-graphics setting completely. It's also what most people actually want: download, print, done.

What I'd tell myself at the start

  • Test on a real printer early. Print preview lies.
  • Draw anything critical in SVG, not CSS backgrounds.
  • Pick fixed paper sizes and ship one version for each.
  • Give users a way to check the scale.
  • Offer a PDF and stop worrying about the browser print dialog.

If you want to see the finished sheets, they're free at printerprinttest.com. I'd genuinely like to hear how other people have handled print CSS, especially the Firefox @page quirks.