CSS media query reference
Media queries apply CSS conditionally based on the device, viewport, or user preferences. A query combines an optional media type (such as screen or print), one or more media features (such as min-width or prefers-reduced-motion), and logical operators (and, ,, not, only). This reference lists every standard feature and operator — including the newer Level 4 range and boolean forms — with values and notes, plus instant search.
How it works
A media query evaluates to true or false; when true, the enclosed rules apply. Range features (width, height, aspect-ratio, resolution) can be written with min-/max- prefixes or, in Level 4, with comparison operators directly inside the parentheses. Discrete features (orientation, prefers-color-scheme, hover, pointer) take a fixed set of keywords. Logical operators chain features: and requires all, a comma means or, not negates, and only shields legacy browsers. The filter matches feature names, values, and descriptions.
Tips and example
Level 4 range syntax is cleaner than paired min/max:
/* old */
@media (min-width: 600px) and (max-width: 900px) { ... }
/* level 4 */
@media (600px <= width <= 900px) { ... }
@media (prefers-color-scheme: dark) {
:root { color-scheme: dark; }
}
- Prefer
prefers-reduced-motion: reduceto pare back animations for users who request it — an accessibility win. pointer: coarseandhover: nonedetect touch devices more reliably than guessing from width alone.- Combine a media type and features with
and; separate alternative whole queries with commas.