---
source: https://iinventedlight.com/library/notes/css-media-queries.md
title: "CSS media queries: styles that respond to viewport and preference"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (web.dev); CC-BY-4.0 (web.dev); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: web.dev, Media queries; web.dev, Responsive web design basics. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: css-media-queries"
tags: [css, media-queries, responsive, viewport, web]
client: Librarian
sources:
  - id: S1
    title: "Media queries"
    publisher: web.dev
    url: https://web.dev/learn/design/media-queries
    accessed: 2026-11-23
    license: "CC-BY-4.0"
  - id: S2
    title: "Responsive web design basics"
    publisher: web.dev
    url: https://web.dev/articles/responsive-web-design-basics
    accessed: 2026-11-23
    license: "CC-BY-4.0"
---
# CSS media queries: styles that respond to viewport and preference
**Answer:** The @media at-rule starts a media query. Designers use queries to react to form factor, including width and aspect ratio. Viewport size is a particularly useful feature. Preference queries can read accessibility settings and theme colors.

## Starting a query

A media query is initiated with @media, a CSS at-rule, and covers many use cases.

Form factor includes width, aspect ratio, and other aspects. Media queries let designers respond.

When the goal is a responsive design, viewport dimensions are a useful media feature.

Combined queries apply their styles only if every condition is true. In this example, the viewport must be at least 50em wide and 30em tall.

Access to user preferences goes beyond height and width, covering accessibility features and theme colors.

## Responsive pages and the viewport tag

Responsive web design is a strategy that adapts layout to the device in use, and it accounts for users' needs plus device capabilities.

A phone might get one column, a tablet two, and a desktop three or four.

When a page is optimized for many devices, a meta viewport tag belongs in the document head.

Without it, the page can load zoomed out and hard to read.

The initial-scale=1 value asks browsers for a 1:1 mapping of CSS pixels to device-independent pixels in any orientation.

Users are used to scrolling websites vertically but not horizontally. Size content to the viewport.

## See also

- [css-cascade](https://iinventedlight.com/library/notes/css-cascade/)
- [css-container-queries](https://iinventedlight.com/library/notes/css-container-queries/)
- [css-flexbox-basics](https://iinventedlight.com/library/notes/css-flexbox-basics/)

## Claims

- id: C1
  claim: Media queries are initiated with the @media keyword.
  source: S1
  evidence: "Media queries are initiated with the @media keyword"

- id: C2
  claim: Viewport dimensions are among the most useful media features for responsive design.
  source: S1
  evidence: "the dimensions of the browser viewport"

- id: C3
  claim: Queries can access user preferences for accessibility features and theme colors.
  source: S1
  evidence: "user preferences for accessibility features and theme colors"

- id: C4
  claim: Responsive web design changes a site's layout to suit the device being used.
  source: S2
  evidence: "changing a site's layout to suit the device being used"

- id: C5
  claim: Pages for a variety of devices must include a meta viewport tag.
  source: S2
  evidence: "must include a meta viewport tag in the head"

## Sources

- [S1] Media queries. web.dev. https://web.dev/learn/design/media-queries . License: CC-BY-4.0. Accessed 2026-11-23.

- [S2] Responsive web design basics. web.dev. https://web.dev/articles/responsive-web-design-basics . License: CC-BY-4.0. Accessed 2026-11-23.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: web.dev, Media queries; web.dev, Responsive web design basics. CC-BY-4.0 (https://web.dev/learn/css/flexbox). Copyright Google LLC. web.dev text is CC BY 4.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
