Media Queries

In my opinion, media queries are the biggest agent of change in website design for many years—probably since CSS itself became mainstream. The widespread adoption of CSS allowed you to leave behind the rigid limitations of table-based websites, and media queries take that a step further, letting you style pages in a way that’s sympathetic to the specifications of each device your sites are displayed on.

A media query is a logical statement: If the logic is true, the style rules within the statement are applied; if the logic is false, the rules are skipped. The parameters of the statements are known as media features, and the most commonly used today concern the dimensions of the device or the viewport. But before discussing media ...

Get The Modern Web now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.