CSSApril 2026 ยท 12 min read

CSS Media Queries & Responsive Breakpoints (2026 Guide)

Master CSS media queries: syntax, common breakpoints, mobile-first design, container queries, prefers-color-scheme, and responsive best practices for 2026.

๐Ÿ“ฑ
Try the Media Query Generator
Free, no signup
โ†’
DG
Derek Giordano
Designer & Developer
In this guide
01What Are Media Queries?02Media Query Syntax03Common Breakpoints04Mobile-First Approach05Useful Media Features06Container Queries07Preference Queries08Best Practices
โšก Key Takeaways
  • Master CSS media queries: syntax, common breakpoints, mobile-first design, container queries, prefers-color-scheme, and responsive best practices for 2026.
  • What Are Media Queries?.
  • Covers media query syntax.
  • Covers common breakpoints in 2026.
  • Covers mobile-first design.

What Are Media Queries?

CSS media queries let you apply styles conditionally based on the user's device, viewport, or preferences. They're the core mechanism behind responsive web design โ€” the technique of building interfaces that adapt to any screen size.

A media query wraps a block of CSS in a condition. If the condition is true, the styles apply. If it's false, they're ignored. The most common condition tests viewport width, but media queries can also detect color scheme preference, reduced motion preference, orientation, resolution, and more.

Media Query Syntax

A media query combines an optional media type with one or more feature conditions:

๐Ÿ’ก Tip
Use gap instead of margin hacks for flexbox spacing. It keeps layout code cleaner and is supported in all modern browsers.
@media screen and (min-width: 768px) {\n .container { max-width: 720px; }\n}

screen is the media type (optional โ€” defaults to all). min-width: 768px is the feature condition. The styles inside only apply when the viewport is at least 768px wide.

You can combine conditions with and, or (comma), and not:

@media (min-width: 768px) and (max-width: 1199px) { }\n@media (orientation: portrait), (max-width: 480px) { }\n@media not print { }

Modern CSS also supports range syntax for cleaner breakpoints:

@media (768px <= width < 1200px) { }

Common Breakpoints in 2026

There's no universal set of "correct" breakpoints โ€” they should be determined by your content, not by specific device dimensions. That said, these ranges cover the vast majority of devices in 2026:

โš  Warning
Avoid animating width, height, top, or left. These trigger layout recalculations on every frame and can drop performance below 60fps.

Mobile: 0โ€“479px (small phones), 480โ€“767px (large phones / landscape)

Tablet: 768pxโ€“1023px (portrait tablet), 1024pxโ€“1199px (landscape tablet / small laptop)

Desktop: 1200pxโ€“1439px (standard desktop), 1440px+ (large desktop)

Modern frameworks tend to use fewer breakpoints: Tailwind CSS uses sm: 640px, md: 768px, lg: 1024px, xl: 1280px, and 2xl: 1536px. Bootstrap uses sm: 576px, md: 768px, lg: 992px, xl: 1200px, and xxl: 1400px.

The trend is toward fewer, content-driven breakpoints rather than device-specific ones. Add a breakpoint when your layout breaks โ€” not because a new device exists.

Mobile-First Design

Mobile-first means writing your base styles for the smallest screens and using min-width queries to add complexity for larger viewports:

/* Base: mobile (no query) */\n.grid { display: flex; flex-direction: column; }\n\n/* Tablet and up */\n@media (min-width: 768px) {\n .grid { flex-direction: row; flex-wrap: wrap; }\n .grid > * { width: 50%; }\n}\n\n/* Desktop */\n@media (min-width: 1200px) {\n .grid > * { width: 33.333%; }\n}

Mobile-first has practical advantages beyond philosophy. Mobile styles load without any media query overhead. Progressive enhancement means the simplest layout is the default, and complexity is layered on only for devices that can handle it.

Useful Media Features Beyond Width

`orientation` โ€” detects portrait vs landscape mode. Useful for adjusting image layouts and navigation patterns on tablets.

`hover` โ€” detects if the primary input can hover. `@media (hover: hover)` targets devices with a mouse/trackpad. Use this to add hover effects only where they work.

`pointer` โ€” detects input precision. `@media (pointer: coarse)` targets touch screens; `@media (pointer: fine)` targets mouse/stylus. Use this to adjust tap target sizes.

`resolution` โ€” detects screen pixel density. `@media (min-resolution: 2dppx)` targets Retina/HiDPI displays for serving higher-resolution images.

`aspect-ratio` โ€” detects viewport proportions. Useful for optimizing layouts for ultra-wide monitors or tall phone screens.

Container Queries

Container queries are a game-changing addition to CSS that let components respond to their container's size rather than the viewport's size. This means a card component can adapt its layout based on the sidebar width it's placed in โ€” not the browser window.

.card-container {\n container-type: inline-size;\n container-name: card;\n}\n\n@container card (min-width: 400px) {\n .card { flex-direction: row; }\n}

Container queries are supported in all modern browsers as of 2023. They're ideal for component libraries and design systems where components are reused in different layout contexts.

Preference Queries

Modern CSS can detect user accessibility and display preferences:

`prefers-color-scheme` โ€” detects dark/light mode preference. Essential for implementing automatic dark mode.

`prefers-reduced-motion` โ€” detects if the user has requested reduced motion. Wrap all animations and transitions in this query to respect accessibility settings.

`prefers-contrast` โ€” detects if the user has requested increased contrast. Useful for enhancing border visibility and text contrast.

@media (prefers-reduced-motion: reduce) {\n *, *::before, *::after {\n animation-duration: 0.01ms !important;\n transition-duration: 0.01ms !important;\n }\n}

Media Query Best Practices

Design for content, not devices. Resize your browser and add breakpoints where the layout starts looking bad โ€” not at iPhone or iPad dimensions.

Use `em` for breakpoint values. `em`-based breakpoints account for user font-size preferences. `@media (min-width: 48em)` equals 768px at default font size but scales appropriately if the user has increased their base font size.

Keep media queries near their components. Instead of one giant media query block at the bottom of your stylesheet, put each component's responsive rules next to its base styles.

Don't hide content from mobile users. Use media queries to rearrange and adapt content, not to remove it. If something isn't important enough for mobile, question whether it should exist at all.

Frequently Asked Questions

What is a CSS media query?+
A CSS media query applies styles conditionally based on the user's device, viewport size, or preferences. The most common use is adjusting layouts at different screen widths for responsive design.
What are the standard responsive breakpoints?+
Common breakpoints are 480px (large phone), 768px (tablet), 1024px (small desktop), 1200px (desktop), and 1440px (large desktop). However, the best practice is to set breakpoints based on where your content breaks, not specific devices.
What is mobile-first CSS?+
Mobile-first means writing base styles for small screens and using min-width media queries to add styles for larger screens. This approach ensures the simplest, lightest styles load by default.
What are container queries?+
Container queries let CSS components respond to their parent container's size instead of the viewport size. This makes components truly reusable across different layout contexts.
Should I use px or em for breakpoints?+
Using em values for breakpoints respects the user's font-size settings. For example, @media (min-width: 48em) equals 768px at the default 16px font size but scales proportionally if the user has changed their base font size.
Try it yourself

Use the Media Query Generator โ€” free, no signup required.

โšก Open Media Query Generator
DG
Derek Giordano
Written by the creator of Ultimate Design Tools. BA in Business Marketing.
โšก Try the free Touch Target Size Checker โ†’