CSS Print Stylesheet

Optimize web pages for printing using CSS print media queries with page breaks and display adjustments for paper output.

CssConfig Management

Code

@media print {
  body { font-size: 12pt; color: black; }
  .no-print { display: none; }
  h1 { page-break-before: always; }
  a::after { content: " (" attr(href) ")"; }
}

CSS Print Stylesheet

Optimize web pages for printing using CSS print media queries with page breaks and display adjustments for paper output.

Code

@media print {
  body { font-size: 12pt; color: black; }
  .no-print { display: none; }
  h1 { page-break-before: always; }
  a::after { content: " (" attr(href) ")"; }
}

Explanation

@media print applies rules only when the page is printed, hiding navigation and controlling page breaks. Expected behavior: backgrounds are dropped by default and the printed sheet shows the content column. Caveat: users can override background printing, and break-inside: avoid is a hint that engines may ignore on very tall blocks.

Interactive Tools for This Topic