MobileCheck

What is a media query in CSS?

Glossary · Updated October 23, 2026 · Also called: @media, CSS media queries

Definition A media query is a CSS condition, written with the @media rule, that applies a block of styles only when the device or browser matches it: for example a viewport at least 600 px wide, a dark color scheme, a touch screen or a preference for reduced motion. Media queries are the core tool of responsive web design and are defined in the W3C Media Queries Level 4 specification.

How do media queries work?

A media query has an optional media type (screen, print or all) and one or more media features in parentheses, combined with and, commas (or) and not. The browser re-evaluates them whenever conditions change, such as when a phone rotates or the user switches to dark mode, and applies the matching rules immediately.

Media features useful on mobile:

Example

/* Two columns on wider screens */
@media (min-width: 600px) { .grid { grid-template-columns: 1fr 1fr; } }

/* Range syntax (Media Queries Level 4) */
@media (600px <= width < 1024px) { .sidebar { display: none; } }

/* Bigger tap areas on touch screens */
@media (pointer: coarse) { .toolbar button { min-height: 44px; } }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) { * { animation: none; } }

The range syntax works in Chrome 104, Firefox 63 and Safari 16.4 and later; for older browsers, use min-width and max-width. You can also test a media query from JavaScript with window.matchMedia('(min-width: 600px)').

Common mistakes

MobileCheck doesn't read your media queries; it shows what they produce on each real device and in dark mode, and flags the problems that result.

Guides and tools

Sources

  1. MDN: Using media queries
  2. W3C: Media Queries Level 4

All 27 glossary terms, A to Z