CSS @media Query Builder
Build CSS media queries visually with support for width, height, orientation, and more. All processing runs client-side.
About This Tool
The CSS @media Query Builder is a free, browser-based tool that
helps you construct CSS media queries without memorizing the
exact syntax for each media feature. Instead of looking up
property names and allowed values, you pick features from a
dropdown, type the desired value, and the tool generates a
ready-to-use @media rule instantly.
You can combine multiple features with and (all conditions must match) or or (comma-separated queries where any condition triggers the rule). A not toggle lets you negate the entire expression so it applies when the conditions are not met.
Supported media features include min-width, max-width,
min-height, max-height, orientation,
prefers-color-scheme, prefers-reduced-motion, pointer,
hover, display-mode, prefers-contrast,
min-resolution, aspect-ratio, and color-gamut. The
preset library provides one-click templates for the most common
responsive breakpoints, dark/light mode, print stylesheets,
and accessibility-related queries.
All processing happens entirely in your browser. No data is sent to any server and no account is required. Click Copy or press Ctrl+Shift+C to copy the generated query to your clipboard.
This tool pairs well with the Viewport Size Reference for checking common device dimensions, the CSS Layout Generator for building responsive layouts, and the Responsive Image Srcset Generator for creating optimized image markup that works alongside media queries.
How to Use
- Select a Media Type (screen, print, all, or speech) from the dropdown at the top.
- Click Add Feature to add a media feature condition. Choose a property such as
min-widthand enter a value like768px. - Add more features as needed. Use the checkbox next to each feature to enable or disable it without removing it.
- Choose whether to combine features with and (all must match) or or (comma-separated, any can match).
- Optionally toggle not to negate the entire media query.
- Review the generated CSS in the output panel on the right (or below on mobile).
- Click Copy or press Ctrl+Shift+C to copy the media query to your clipboard. Alternatively, click a Common Preset to load a popular query instantly.
Popular Media Query Guides
FAQ
Is my data safe when using this tool?
Yes. All processing runs entirely in your browser using JavaScript. No data is sent to any server. Your media query is generated locally and never transmitted anywhere.
What is the difference between 'and' and 'or' combining?
Using 'and' means all conditions must be true for the query to match. Using 'or' creates comma-separated queries where the styles apply if any one condition matches. In CSS, commas between media queries act as a logical OR.
What does the 'not' toggle do?
The 'not' keyword negates the entire media query. For example, '@media not screen and (min-width: 768px)' applies to everything except screens that are at least 768px wide.
What is 'prefers-color-scheme'?
prefers-color-scheme is a CSS media feature that detects whether the user has set their operating system or browser to a light or dark color theme. You can use it to apply dark mode or light mode styles automatically.
What is 'prefers-reduced-motion'?
prefers-reduced-motion detects if the user has requested minimal animation in their OS accessibility settings. When set to 'reduce', you should disable or simplify animations for users who experience motion sickness or have vestibular disorders.
Can I use multiple min-width queries together?
Yes. You can add multiple features with different values. For example, combining min-width: 768px and max-width: 1024px with 'and' targets tablet-sized viewports specifically.
What is the pointer media feature?
The 'pointer' feature detects the primary pointing device. 'fine' indicates a mouse or trackpad (precise clicking), 'coarse' indicates a touchscreen (less precise), and 'none' means no pointing device is available.
Related Tools
Responsive Image Srcset Generator
Generate responsive img srcset and picture element markup for optimal image loading across devices.
CSS Layout Generator
Visually build Flexbox and CSS Grid layouts with live preview and generated CSS code.
Viewport Size Reference
Browse 60+ device viewport sizes for responsive web design. Compare iPhone, iPad, Android, laptop, desktop, and TV screen dimensions.
Tailwind Config Builder
Build tailwind.config.js visually with custom colors, spacing, fonts, and breakpoints.
CSS Container Query Builder
Build CSS container queries visually with container type, name, and size conditions.