liveBook · Manning

Media type

As explained in CSS in Depth, Second Edition

A CSS media type identifies the broad output medium, such as a screen or printed page, for conditional styling.

A media type identifies the broad output medium for conditional CSS. The commonly used types are screen and print; print rules adapt a page for physical output. section 7.2.1

Use media types to make printed pages clearer and less wasteful:

  • Write print-only rules with @media print; unlike min-width queries, this form needs no parentheses. section 7.2.1
  • Hide nonessential navigation and footers with display: none so printed output emphasizes the main content. section 7.2.1
  • Remove background images and colors, and change text to black, to reduce ink use and improve print clarity. section 7.2.1

A basic print reset

A universal print rule can force black text and remove backgrounds: @media print { * { color: black !important; background: none !important; } }. section 7.2.1

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

Inspect a compact print rule that overrides screen-oriented colors and backgrounds. section 7.2.1

How CSS in Depth, Second Edition covers it

How deep it goes
Defines screen and print queries and demonstrates practical print rules without descending into rendering internals.
Examples
Uses printed pages, hidden navigation and footers, removed backgrounds, and globally blackened text as concrete examples.
What you can do after
Apply it via CSS media queries to create screen-specific or print-specific presentation rules.
How it connects
Ties media types to media queries, print styles, navigation visibility, and background or text color changes.

Related concepts

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.