Media Queries in CSS

From the CSS cheat sheet ยท Media Queries & Responsive ยท verified Jul 2026

Media Queries

Responsive breakpoints, user preferences, and container queries

css
/* Mobile-first breakpoints */
@media (min-width: 640px)  { /* sm */ }
@media (min-width: 768px)  { /* md */ }
@media (min-width: 1024px) { /* lg */ }
@media (min-width: 1280px) { /* xl */ }

/* Dark mode */
@media (prefers-color-scheme: dark) { }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) { }
๐Ÿ’ก Mobile-first (min-width) is the standard โ€” start small, add complexity for larger screens
โšก Container queries let components respond to their container size, not the viewport
๐Ÿ“Œ Always respect prefers-reduced-motion โ€” disable animations for users who need it
๐ŸŸข See the Screen Sizes & Responsive Breakpoints sheet for device dimensions and patterns
media-queriesresponsivecontainer-queries

More CSS tasks

Back to the full CSS cheat sheet