Home Tools Blog About

CSS Media Query Generator

In short

Build @media queries: width, dark mode, reduced-motion, hover, pointer, orientation, print. Free, offline, client-side, instant.

  • Runs in your browser
  • Nothing uploaded
  • Free, no sign-up

Build compound CSS media queries: width, dark mode (prefers-color-scheme), reduced-motion, hover capability, pointer precision, orientation, retina resolution, PWA display-mode, and print. With em-conversion for accessibility-friendly breakpoints and SCSS output.

Media type

Add a width condition

Quick-add modern conditions

Active conditions (combined with AND)

CSS body (inside the @media block)

CSS


      

SCSS


      
🛡
100% PrivateNo server uploads, ever
InstantRuns in your browser
💧
No WatermarksClean output, always
🆓
Free ForeverNo accounts, no limits

How to Use CSS Media Query Generator

  1. Pick a media type (screen is the default; pick print for print stylesheets).
  2. Add a width condition: set min-width (mobile-first, recommended) or max-width (desktop-first). Choose a unit. em is more accessible than px because it respects user zoom.
  3. Or pick a device preset (Mobile S, Tablet, Laptop, 4K) for a quick start.
  4. Click any quick-add chip for modern feature queries: dark mode, reduce motion, touch only, retina, PWA installed, and more.
  5. Conditions stack and combine with and. Click the remove button to drop any.
  6. Edit the CSS body, which is what goes inside the @media { ... } block.
  7. Copy as plain CSS or as SCSS (the @media block, ready for nesting).

Frequently Asked Questions

Why use em instead of px for media queries?

em-based breakpoints respect the user’s browser zoom and default font size. If a user has set their browser to use 20px as the base font (a large-text accessibility setting), a 48em breakpoint equals 960px instead of 768px, so the layout adapts to their font scale, not yours. With px breakpoints the layout snaps at the same screen width regardless of user font settings, which can produce broken layouts for low-vision users.

How do I detect dark mode?

@media (prefers-color-scheme: dark). The browser reports the user’s OS theme preference. To handle both, write your default styles in light, then override inside a dark-mode media query. There is also (prefers-color-scheme: light) for users who explicitly opted to light when their OS defaults to dark.

What is prefers-reduced-motion?

A user setting on macOS, iOS, Windows, and Android that asks for reduced animation. @media (prefers-reduced-motion: reduce) matches when set. Inside, kill or simplify animations, for example * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }. It supports WCAG 2.1 compliance and is increasingly enforced legally.

hover vs pointer, what is the difference?

hover reports whether the input device can hover (mouse yes, finger no). pointer reports its precision (mouse fine, finger coarse, eye-tracking none). They overlap a lot but not perfectly: a 2-in-1 laptop with a touchscreen reports both across input modes, and most browsers report the PRIMARY input device.

How do I target retina displays?

@media (min-resolution: 2dppx) matches devices with at least 2 device pixels per CSS pixel (Retina, 4K phones, and so on). For 3x devices use (min-resolution: 3dppx). Use it to serve 2x or 3x images via background-image swaps. The older -webkit-min-device-pixel-ratio syntax is no longer needed in 2026.

Can I do range queries with cleaner syntax?

Yes, since the Media Queries Level 4 spec. Instead of @media (min-width: 768px) and (max-width: 1024px), you can now write @media (768px <= width <= 1024px). Browser support reaches all majors as of mid-2026. This tool emits the classic syntax because some build tools still mangle the range form.

What is display-mode for PWAs?

When a user installs your web app to their home screen, the browser sets a display mode. @media (display-mode: standalone) matches when running as an installed PWA, which is useful for hiding install banners or showing app-specific UI like a back button. Other values include fullscreen, minimal-ui, and the default browser.

Why does this tool only combine with AND?

Comma in @media means OR: @media (max-width: 600px), (min-width: 1200px) means small OR large. This tool combines with AND because OR queries with mixed-direction widths often turn into bugs in production. If you need OR, write two separate @media blocks for the same effect with clearer intent.

Is my data secure?

Yes. Conditions, breakpoint values, and CSS body stay in your browser. Nothing is uploaded.

Keep going

Related Tools

All Developer tools →

CSS Animation Generator

Generate CSS @keyframes animations - 16 presets, full duration/timing/delay/direction/fill controls, prefers-reduced-motion wrapper. Live preview.…

CSS Aspect Ratio

Generate CSS aspect-ratio with padding-top fallback, object-fit options, 16+ presets, decimal input. Live preview.…

CSS Beautifier

Beautify or minify CSS with proper nested @media/@keyframes/@supports handling, comment preservation, calc()/var() awareness. Free,…

CSS Border Radius Generator

Visual CSS border-radius with elliptical mode, 6 unit types (px/%/em/rem/vw/vh), 8 shape presets, live…

CSS Clip Path Generator

Visual clip-path builder - polygon / circle / ellipse / inset / path, 20+…

CSS Columns Generator

Generate CSS multi-column layout with column-count or column-width, gap, rule, fill, span, break-inside. Live…

CSS Cursor Generator

Browse 34 CSS cursors organized by category, with custom URL cursor builder. Live hover…

CSS Filter Generator

Generate CSS filter with 10 functions including drop-shadow, backdrop-filter mode, 8 preset combinations. Live…

CSS Flexbox Generator

Visual flexbox builder with container + per-item controls (flex-grow/shrink/basis/order/align-self) and 6 layout presets. Free,…

CSS Glassmorphism Generator

Visual frosted-glass CSS builder. 9 controls including backdrop-saturate, 6 presets, 4 background scenes to…

CSS Gradient Generator

Visual gradient builder with 6 types (linear, radial, conic + 3 repeating). 8 presets,…

CSS Grid Generator

Visual CSS Grid builder with grid-template-areas, auto-fit + minmax responsive tracks, per-item spans. 6…

Share

Embed this tool

Add this free tool to your website. Copy and paste the code: