๐Ÿ–จ๏ธ CSS

CSS Print Styles โ€” Make Your Pages Print Properly

๐Ÿ“… Jul 3, 2026 โฑ 2 min read

Students print notes and results pages constantly โ€” and most sites print terribly. 20 lines fix yours.

The essential print block

@media print {
  nav, footer, .sidebar, .ad-unit, button, .no-print { display: none; }

  body { background: #fff; color: #000; font-size: 12pt; }
  main { max-width: 100%; margin: 0; }

  a { color: #000; text-decoration: underline; }
  /* print the URL after external links */
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; }

  h2, h3 { break-after: avoid; }        /* no heading orphaned at page bottom */
  pre, table, img { break-inside: avoid; }
  .chapter { break-before: page; }      /* force new page */
}

Test without paper

Ctrl/Cmd+P shows the live preview โ€” or DevTools โ†’ Rendering โ†’ "Emulate CSS media type: print" to inspect print styles like normal CSS.

โ† All Articles