liveBook · Manning

Print styles

As explained in CSS in Depth, Second Edition

Print styles are CSS rules that define how a web document is formatted for printed output.

Print styles are CSS rules that reshape a web page for printed output. They preserve the main content while removing screen-oriented elements and ink-heavy decoration. section 7.2.1

Apply the basic print treatment inside a print media query:

  • Write @media print without parentheses; use @media screen when targeting screen output. section 7.2.1
  • Hide nonessential elements such as navigation menus and footers with display: none. section 7.2.1
  • Change font colors to black and remove background images and colors to reduce ink use. section 7.2.1

A minimal ink-saving rule

@media print { * { color: black !important; background: none !important; } } section 7.2.1

@media print {
  * {
    color: black !important;
    background: none !important;
  }
}

Inspect the compact universal rule for forcing black text and removing backgrounds during printing. section 7.2.1

How CSS in Depth, Second Edition covers it

How deep it goes
Explains media-query syntax and practical print adjustments, but stops short of detailed page-specific print layouts.
Examples
Uses navigation, footers, background imagery, black text, and an ink-saving universal selector as concrete examples.
What it assumes
Assumes familiarity with CSS rules and media queries while introducing print and screen media types from their syntax.
What you can do after
Apply print-specific CSS with @media print to hide nonessential content and simplify printed colors and backgrounds.
How it connects
Connects media queries with CSS cascade, screen styles, navigation, footers, backgrounds, and typography.

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.