Home/Tools/Utilities/Media Query Generator
Utilities · Generator

Media Query Generator

Generate responsive media queries for all device sizes.

Breakpoint Preset

Custom Media Query

768px
@media (min-width: 768px)

Mobile First Breakpoints

sm≥ 640px
md≥ 768px
lg≥ 1024px
xl≥ 1280px
2xl≥ 1536px

Visual Guide

sm
md
lg
xl
2xl
0px1920px
Generated CSS
/* Mobile First Breakpoints */
@media (min-width: 640px) { /* sm */ }
@media (min-width: 768px) { /* md */ }
@media (min-width: 1024px) { /* lg */ }
@media (min-width: 1280px) { /* xl */ }
@media (min-width: 1536px) { /* 2xl */ }

/* Custom Media Query */
@media (min-width: 768px) {
  /* Your styles here */
}
100%
Free, no
sign-up needed
0
Code written
by hand
85+
CSS tools
in one place
<1s
Copy-ready
CSS instantly
What is this

What is the CSS Media Query Generator?

Generate responsive breakpoint CSS for common screen sizes. Mobile-first or desktop-first syntax with instant copy.

Everything runs locally in your browser. Adjust the controls above, preview instantly, and copy clean, production-ready CSS — no account, no upload.

How to use

Using the CSS Media Query Generator

Everything lives in the panel at the top of this page. There is nothing to install — it all runs right here in your browser.

1

Choose mobile-first or desktop-first

Mobile-first uses min-width. Desktop-first uses max-width. Mobile-first produces smaller CSS and aligns with the progressive enhancement principle.

2

Select your breakpoints

Choose from common breakpoints (480px, 768px, 1024px, 1280px, 1536px) or enter custom values.

3

Copy the skeleton

The generated code is an empty breakpoint structure. Add your property overrides inside each media query block.

The output

What the generated code looks like

Clean, production-ready CSS — no vendor bloat, no unnecessary declarations.

responsive.css
/* Mobile first: default styles apply to all screens */
.container {
  padding: 16px;
  font-size: 1rem;
}

/* Tablet: 768px and above */
@media (min-width: 768px) {
  .container {
    padding: 32px;
    font-size: 1.0625rem;
  }
}

/* Desktop: 1024px and above */
@media (min-width: 1024px) {
  .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px;
  }
}

Mobile-first (min-width) is the recommended approach. CSS is smaller because base styles apply to all widths without media queries. Overrides only add detail for larger screens.

Common mistakes & fixes

Common mistakes & how to fix them

A few habits trip people up. Here is what to watch for — and the exact fix.

Mixing min-width and max-width creates overlapping ranges

Using both min-width: 768px and max-width: 767px for adjacent breakpoints creates a 1px gap or overlap depending on fractional device pixel ratios.

Fix: Pick one approach (mobile-first or desktop-first) and use it consistently. If you must combine them, use a range: @media (min-width: 768px) and (max-width: 1023px).

Pro tips

Pro tips for better results

Use logical pixels, not physical pixels

Device pixel ratio means a 4K display has a physical resolution of 3840px but reports a CSS width of 1920px. Media queries use logical (CSS) pixels, not physical pixels. No adjustment needed for high-DPI displays.

Container queries are now supported everywhere

Chrome 105+, Firefox 110+, and Safari 16+ all support @container queries. Container queries respond to parent element width rather than viewport width, enabling truly reusable components.

FAQ

Frequently asked questions

Common breakpoints match real device widths: 480px (large phone), 768px (tablet portrait), 1024px (tablet landscape / small desktop), 1280px (desktop), 1536px (large desktop). Your design should drive breakpoints, not preset values.
Use the prefers-color-scheme media feature: @media (prefers-color-scheme: dark) { }. This detects the OS-level dark mode setting and is supported in Chrome 76+, Firefox 67+, Safari 12.1+.

From the blog

Read more