UTILS.
Private by default
@

CSS Media Query Builder

Build a responsive @media query with presets and copy it.

Your files stay on this device

Files are processed in your browser, never uploaded. The site downloads code and assets to run the tools. No accounts or trackers.

Use Download to save this tool as one HTML file for offline use.

Privacy →

About this tool

Media Query Builder writes the opening of a responsive @media rule. Pick min-width, max-width or a range, enter pixel values, optionally restrict to portrait or landscape orientation, and copy the result. Three preset buttons fill in common breakpoints: Mobile sets max-width 767px, Tablet sets a range of 768px to 1023px, and Desktop sets min-width 1024px.

The output is a complete rule skeleton such as @media (min-width: 768px) and (max-width: 1023px) { /* ... */ } with an empty comment where your styles go. Conditions are joined with and. Widths are whole pixel numbers: decimals are cut to integers and blank or negative entries become 0. The tool does not warn if the minimum is larger than the maximum, which would never match any screen.

A min-width query is the usual mobile-first approach, applying styles from a width upward, while max-width applies up to a width. Using 767 and 768 rather than the same number for neighbouring ranges avoids a one-pixel overlap. Only width and orientation are supported, not height, resolution or prefers-color-scheme. The preset values are conventions, not standards. Everything is generated in your browser.

Frequently asked questions

What is the difference between min-width and max-width?
min-width applies the styles once the viewport is at least that wide, which suits mobile-first design. max-width applies them only up to that width. A range combines both.
How do the device presets work?
They only fill in the fields: Mobile sets max-width 767px, Tablet sets 768px to 1023px and Desktop sets min-width 1024px. You can edit the numbers afterwards.
Can I use units other than pixels?
No. The fields take whole numbers and the output always uses px. Convert em or rem breakpoints yourself, for example 48em is 768px at the default 16px size.
Does it support height or other features?
Only width and orientation are generated. For other media features, edit the copied text by hand.

More tools