CSS Snippet

CSS Media Query Recipes (Retina, DPI, Color Depth, Aspect Ratio)

Difficulty: Medium

Media queries do far more than `min-width`. This snippet collects the recipes you reach for in real projects: viewport breakpoints, high-DPI / retina screens, color-depth and color-gamut gating, user preference queries (`prefers-color-scheme`, `prefers-reduced-motion`), and aspect-ratio plus orientation for video and game UIs. Drop the ones you do not need; keep the rest as a starting point.

Code Snippets
/

CSS Media Query Recipes (Retina, DPI, Color Depth, Aspect Ratio)

CSS Media Query Recipes (Retina, DPI, Color Depth, Aspect Ratio)

Media queries do far more than `min-width`. This snippet collects the recipes you reach for in real projects: viewport breakpoints, high-DPI / retina screens, color-depth and color-gamut gating, user preference queries (`prefers-color-scheme`, `prefers-reduced-motion`), and aspect-ratio plus orientation for video and game UIs. Drop the ones you do not need; keep the rest as a starting point.

CSS
Medium
4 snippets
css-media-queries
css-responsive-design
css-units

874 views

13

Mobile-first means your base CSS is the smallest screen and each @media (min-width: ...) block layers on richer styles for larger viewports. This avoids the override-fest that happens when you write desktop styles first and then max-width queries to undo them. Pick three or four breakpoints and stick with them; common starting points are 640px (small tablet), 1024px (small laptop), and 1440px (large desktop). Use rem and % for sizing inside the queries so a user changing the browser zoom or root font size still gets a comfortable layout.