liveBook · Manning

Media query range syntax

As explained in CSS in Depth, Second Edition

Media query range syntax is CSS notation that expresses lower and upper bounds with comparison operators around a media feature.

Media query range syntax expresses viewport conditions with comparison operators, replacing verbose min-width and max-width combinations with notation that reads like a range. section 7.2.1

Set an inclusive viewport range

Use @media (800px <= width <= 1200px) when a rule should apply from 800px through 1200px. Exclusive operators omit the equality sign, as in @media (800px < width < 1200px). section 7.2.1

@media (480px <= width < 1200px) { ... }
@media (800px < height) { ... }
@media (width = 1600px) { ... }

Compare bounded, one-sided, and exact-width media query expressions. section 7.2.1

Use the syntax when:

  • A single expression should describe both lower and upper viewport bounds. section 7.2.1
  • Adjacent breakpoints must avoid overlapping at an exact size; choose < or <= deliberately. section 7.2.1
  • Check current browser support because the syntax remains relatively new. section 7.2.1

How CSS in Depth, Second Edition covers it

How deep it goes
Explains bounded, one-sided, inclusive, and exclusive forms, but defers detailed browser compatibility statistics.
Examples
Uses 800px–1200px bounds and contrasts inclusive, exclusive, one-sided, and exact-width expressions.
What it assumes
Assumes familiarity with media queries and min-width or max-width conditions.
What you can do after
Apply range syntax to write readable responsive conditions and control breakpoint overlap.
How it connects
Connects media features with responsive design, breakpoints, and classic min-width and max-width queries.

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.