Media query generator — breakpoint templates for responsive CSS

Pick a breakpoint system and an approach, and the tool writes a ready set of empty @media blocks in the right order, plus optional queries for dark mode, reduced motion, hover, landscape and print.

Live demo · real result from this tool
Approach
Units

media-queries.css

/* Tailwind CSS breakpoints — mobile-first */ /* Base styles target the smallest screens; each block adds styles from a width up. *//* sm: 640px and up */@media (min-width: 640px) {  /* … */} /* md: 768px and up */@media (min-width: 768px) {  /* … */} /* lg: 1024px and up */@media (min-width: 1024px) {  /* … */} /* xl: 1280px and up */@media (min-width: 1280px) {  /* … */
}

/* 2xl: 1536px and up */
@media (min-width: 1536px) {
  /* … */
}

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

@media (prefers-reduced-motion: reduce) {
  /* … */
}

Processed on your device — nothing is uploaded.

How to use the media query generator

  1. Choose the Breakpoints: Tailwind CSS, Bootstrap 5, Material Design 3 window classes, Simple (phone / tablet / desktop) or Custom.
  2. For Custom, list Custom breakpoints (name: px), one per line, such as tablet: 768.
  3. Pick the Approach: Mobile-first (min-width), Desktop-first (max-width) or Range syntax.
  4. Choose Units: px, em or rem.
  5. Tick the extra queries you want, Dark mode, Reduced motion, Hover-capable pointer, Short landscape screens and Print, then copy the CSS.

What it does and when to use it

Media queries let one stylesheet change the layout at certain screen widths, called breakpoints. Typing them out is easy, but keeping the order, the units and the exact numbers consistent across a project is where mistakes creep in. This tool gives you the whole skeleton at once, matching a known system.

Use it when you start a stylesheet, or when you want your own CSS to break at the same widths as Tailwind or Bootstrap components on the same page. Pair it with the CSS reset generator and the CSS variables generator for a full starting stylesheet. In a Tailwind project, add an extra breakpoint with the Tailwind config generator instead. MDN’s guide to using media queries explains every feature.

How it works

System Breakpoints (px)
Tailwind CSS sm 640, md 768, lg 1024, xl 1280, 2xl 1536
Bootstrap 5 sm 576, md 768, lg 992, xl 1200, xxl 1400
Material Design 3 medium 600, expanded 840, large 1200, extra-large 1600
Simple tablet 768, desktop 1024, wide 1440

Mobile-first lists blocks from small to large with min-width. Desktop-first lists them from large to small with max-width set 0.02px below each breakpoint. Range syntax uses width >= and adds one example block between the first two breakpoints. Custom breakpoints are sorted by size, and em or rem values are px ÷ 16.

Worked examples

Tailwind, mobile-first, px. With the extra queries unticked, the output is five blocks, from @media (min-width: 640px) { to @media (min-width: 1536px) {, each with a comment such as /* lg: 1024px and up */.

Bootstrap 5, desktop-first.

/* below lg (992px) */
@media (max-width: 991.98px) {
  /* … */
}

The blocks run from max-width: 1399.98px down to 575.98px.

Custom sizes in em with range syntax. Breakpoints phone 480, tablet 768, laptop 1200, Hover-capable pointer ticked. You get @media (width >= 30em), 48em and 75em, then @media (30em <= width < 48em) { for phone-only styles, and @media (hover: hover) and (pointer: fine) { for mouse and trackpad users.

Limits and tips

  • Container queries are not generated. For components that respond to their parent’s width rather than the screen, write @container rules yourself.
  • Test real devices. Breakpoints are a starting point; add one where your layout actually breaks.
  • Custom lines without a positive number are ignored.

Frequently asked questions

Mobile-first or desktop-first?
Mobile-first writes base styles for small screens and adds min-width blocks for larger ones. It usually leads to less CSS and matches Tailwind and Bootstrap. Desktop-first, with max-width, suits an existing desktop design that you are making work on phones.
Why does the desktop-first output use 767.98px instead of 768px?
A max-width of 768px and a min-width of 768px would both match a window exactly 768px wide. Subtracting 0.02px avoids that overlap, even at fractional widths on zoomed screens. Bootstrap uses the same trick.
Should breakpoints be in px or em?
px is the simplest and the most common. em breakpoints follow the reader's default font-size setting, so a person who enlarges text gets the narrower layout sooner. The tool converts with 16px = 1em or 1rem.
Can I use the range syntax everywhere?
The range form, such as (width >= 48em), is supported in all current browsers. If you must support much older browsers, choose the min-width or max-width approach instead.
Why are the blocks empty?
The tool gives you the structure; you fill in the rules. Each block has a placeholder comment where your styles go.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close