CSS Tools

Media Query Generator

Use this free Media Query Generator to wrap your CSS in responsive breakpoints instantly. Paste your styles, pick a breakpoint or framework preset, and get formatted media query code ready to drop into your stylesheet. Supports mobile-first, desktop-first, orientation, retina, and print queries. No sign-up required.

Paste Your Own CSS Framework Presets 100% Free

Your CSS Code

Tip: Paste your CSS code and select breakpoints to generate media queries instantly

Select Breakpoints

Mobile First (min-width)

Desktop First (max-width)

Specific Ranges

Special Queries

Output

Current Selection:

No breakpoint selected yet

Common Breakpoint Reference

Bootstrap

576, 768, 992, 1200, 1400

Tailwind CSS

640, 768, 1024, 1280, 1536

Material Design

600, 960, 1280, 1920

Foundation

640, 1024, 1200, 1440

Why You Are Here

Most media query tools give you an empty @media block and leave you to fill in the styles yourself. That saves you typing about fifteen characters. This tool works the other way around: you paste the CSS you have already written, choose the breakpoint you want it to apply at, and get the complete wrapped rule back with proper indentation.

That difference matters because writing media queries is rarely about remembering the syntax. It is about three other things that slow developers down.

The first is breakpoint values. You are working in a Bootstrap project and cannot remember whether the large breakpoint is 992px or 1024px. You are on a Tailwind project next week and the numbers are completely different. Every framework picked its own scale, and switching between projects means constantly looking up values you half-remember. Selecting a framework preset removes that lookup entirely.

The second is the mobile-first versus desktop-first decision, and getting the direction right once you have chosen. Mixing min-width and max-width inconsistently across a stylesheet produces overlapping rules that fight each other, and the resulting bugs only appear at specific viewport widths that are easy to miss during testing.

The third is the queries nobody memorises. Retina display targeting, print stylesheets, orientation, and the accessibility preference queries all have syntax that most developers look up every single time because they write them a few times a year at most.

What This Tool Does

Panel Function
Left panel Paste the CSS rules you want to apply conditionally. This can be a single rule or a full block of styles.
Middle panel Choose how the query should be built: mobile-first min-width, desktop-first max-width, a specific device range, or a special query such as orientation, retina, or print. Framework presets for Bootstrap, Tailwind CSS, Material Design, and Foundation live here.
Right panel The finished media query appears with your CSS correctly nested and indented, ready to copy.
Everything runs in your browser. No CSS is uploaded, stored, or transmitted.

Mobile-First vs Desktop-First

This is the single most important decision when writing media queries, and it determines which direction every one of your breakpoints points.

Mobile-first uses min-width

Your base CSS, written outside any media query, applies to the smallest screens. Each breakpoint then adds or overrides styles for that width and everything above it. Styles cascade upward.

/* base: applies to all screens */
.card { padding: 16px; }

/* 768px and wider */
@media (min-width: 768px) {
  .card { padding: 32px; }
}

Desktop-first uses max-width

Your base CSS targets desktop, and each breakpoint overrides styles for that width and everything below it. Styles cascade downward.

/* base: applies to all screens */
.card { padding: 32px; }

/* 767px and narrower */
@media (max-width: 767px) {
  .card { padding: 16px; }
}
Mobile-first is the recommended default for new projects. It matches how Bootstrap, Tailwind, and Material Design are built, it keeps the base stylesheet lighter for mobile devices, and it forces you to design for the constrained case first. Desktop-first is a reasonable choice when you are retrofitting responsiveness onto an existing desktop-only layout and do not want to rewrite the base styles.

Framework Breakpoint Reference

The four frameworks the tool supports use four different breakpoint scales. This is the table developers look up constantly.

Label

Bootstrap 5 Tailwind CSS Material Design Foundation

Extra small

0px (no query)

0px (no query)

0px

0px (small)

Small

576px

640px

600px

640px (medium)

Medium

768px

768px

900px

1024px (large)

Large

992px

1024px

1200px

1200px (xlarge)

Extra large

1200px

1280px

1536px

1440px (xxlarge)

Extra extra large

1400px

1536px

Two things worth noting. Tailwind and Bootstrap agree on 768px for medium and nothing else. Foundation shifts its labels one step across, so Foundation's medium at 640px lines up with Tailwind's small, which catches people out when migrating between the two.

Common Device Width Reference

Useful when you need to target a real device band rather than a framework step.

Device Category

Typical Width Range Common Breakpoint Used

Small phones

320px to 374px

320px

Standard phones

375px to 413px

375px

Large phones

414px to 480px

414px

Small tablets, portrait

600px to 767px

600px

Tablets, portrait

768px to 833px

768px

Tablets, landscape

1024px to 1199px

1024px

Laptops

1280px to 1439px

1280px

Desktops

1440px to 1919px

1440px

Large desktops

1920px and above

1920px

Match your breakpoints to where your layout actually breaks, not to a specific phone model. Device dimensions change every year; the width at which your three-column grid stops fitting does not.

Special Query Reference

The queries that are hard to remember because you write them rarely.

Purpose Query Syntax

Portrait orientation

@media (orientation: portrait)

Landscape orientation

@media (orientation: landscape)

Retina and high-DPI screens

@media (min-resolution: 2dppx)

Print stylesheet

@media print

Screen only

@media screen

Dark mode preference

@media (prefers-color-scheme: dark)

Reduced motion preference

@media (prefers-reduced-motion: reduce)

Touch input, no fine pointer

@media (pointer: coarse)

Mouse or trackpad input

@media (pointer: fine)

Hover capability present

@media (hover: hover)

The last three are increasingly useful. Targeting hover: hover lets you write hover styles that never fire on touch devices, which prevents the sticky-hover bug where a tapped element stays in its hover state after the finger lifts.

How to Use This Tool

  1. Paste Your CSS

    Copy the CSS rules you want to apply conditionally into the left input panel. This can be a single rule or a full block of styles.

  2. Choose Your Breakpoint Approach

    Select mobile-first for a min-width query, desktop-first for max-width, a specific range to target one device band, or a special query for orientation, retina, or print. Use a framework preset if your project runs on Bootstrap, Tailwind, Material Design, or Foundation.

  3. Review the Generated Query

    The right panel shows the complete media query with your CSS nested and indented correctly.

  4. Copy Into Your Stylesheet

    Copy the output and paste it into your CSS file, ideally near the rules it modifies rather than in a separate breakpoints section at the bottom.

Use Cases Reference Table

Who Uses It

What They Generate Purpose

Front-end developers

Framework-matched breakpoints

Consistency with Bootstrap or Tailwind config

WordPress theme developers

Mobile and tablet overrides

Responsive theme layouts

Email developers

Max-width queries

Mobile email client rendering

Accessibility engineers

Reduced-motion and dark-mode queries

Respecting user system preferences

UI developers

Hover and pointer queries

Preventing sticky hover on touch devices

Print stylesheet authors

Print media queries

Clean printed pages without navigation

Designers learning CSS

Any breakpoint

Learning syntax through generated examples

Common Mistakes to Avoid

Creating a One-Pixel Gap Between Max-Width and Min-Width Breakpoints

If one rule uses max-width: 768px and the next uses min-width: 768px, both fire at exactly 768px and the later rule wins unpredictably. If you instead write max-width: 767px and min-width: 768px, fractional viewport widths on high-DPI screens can land between them and match neither. The standard fix is subtracting a small fraction rather than a whole pixel: pair max-width: 767.98px with min-width: 768px. Bootstrap uses exactly this approach.
Targeting Specific Devices Instead of Layout Breaking Points

Writing a breakpoint at 390px because that is the width of a current iPhone produces a stylesheet that ages badly and breaks on every device you did not think of. Resize your layout in the browser until it stops looking right, and put the breakpoint there. Content-driven breakpoints survive new device releases; device-driven breakpoints do not.
Mixing Mobile-First and Desktop-First in the Same Stylesheet

A stylesheet that uses min-width in some places and max-width in others becomes very difficult to reason about, because the direction of the cascade changes depending on which rule you are reading. Rules end up overriding each other in ways that only appear at particular viewport widths. Pick one approach for the project and apply it consistently, with narrow exceptions only where a genuinely bounded range is needed.

Quick Reference

Item Value

Mobile-first

min-width

Desktop-first

max-width

Tablet breakpoint

768px

Laptop breakpoint

1024px

Desktop breakpoint

1280px

Retina

min-resolution: 2dppx

Print

@media print

Dark mode

prefers-color-scheme: dark

Framework presets

Bootstrap, Tailwind, Material, Foundation

Server upload

No

Frequently Asked Questions

What is a media query generator?

A media query generator is a free online tool that creates responsive CSS media queries for you. This Media Query Generator goes further than most: you paste your existing CSS into the tool, choose a breakpoint or framework preset, and it returns your styles already wrapped in a correctly formatted @media rule ready to paste into your stylesheet.

What is the difference between min-width and max-width?

min-width applies styles when the viewport is at least the specified width, so a min-width: 768px rule affects 768px and everything wider. This is the mobile-first approach. max-width applies styles when the viewport is at most the specified width, so max-width: 768px affects 768px and everything narrower. This is the desktop-first approach. Mobile-first is recommended for new projects.

What are the most common breakpoints?

The most widely used breakpoints are 576px or 640px for small screens, 768px for tablets, 1024px for laptops, 1280px for desktops, and 1536px for large displays. The exact values depend on your framework: Bootstrap uses 576, 768, 992, 1200, and 1400, while Tailwind uses 640, 768, 1024, 1280, and 1536.

Which framework presets does the tool support?

The tool includes breakpoint presets for Bootstrap, Tailwind CSS, Material Design, and Foundation. Selecting a preset loads that framework's exact breakpoint values so your custom media queries line up with the framework's built-in responsive utilities rather than sitting slightly out of step with them.

Can I generate media queries for retina and high-DPI displays?

Yes. The tool includes special queries covering high-resolution displays, orientation, and print. A retina query uses min-resolution: 2dppx to target screens with double the standard pixel density, which is where you would serve higher-resolution background images or adjust border widths that look too thin on dense displays.

Should I use mobile-first or desktop-first?

Mobile-first is the better default for new projects. It keeps the base stylesheet lightweight for mobile devices, matches how modern frameworks are built, and encourages designing for the constrained case first. Desktop-first is a practical choice when you are adding responsiveness to an existing desktop-only site and do not want to restructure the base styles.

Where should media queries go in my stylesheet?

Place each media query directly after the rules it modifies rather than grouping all breakpoints in a block at the bottom of the file. Keeping the base rule and its responsive overrides adjacent makes the relationship obvious to anyone reading the code and makes it much harder to forget updating one when you change the other.

Is my CSS uploaded anywhere when I use this tool?

No. This Media Query Generator processes everything locally in your browser. The CSS you paste is never uploaded, stored, or transmitted to EveryWebTool.com or any third party. You can safely paste proprietary or client CSS with no account and no data collection.

Comments

Login to leave a comment

No comments yet. Be the first to comment!