Skip to main content

Build Responsive CSS Media Queries Generate CSS media queries with feature conditions and preset breakpoints.

Media Query Generator illustration
🎨

Media Query Generator

Generate CSS media queries with feature conditions and preset breakpoints.

1

Use a preset or build custom

Select a common preset or add custom conditions with media features.

2

Configure conditions

Set media type, feature conditions, and combine with AND or OR operators.

3

Copy the query

Copy the generated media query ready to use in your stylesheet.

Loading tool...

What Is Media Query Generator?

The Media Query Generator helps you build CSS media queries for responsive design and feature detection. Media queries conditionally apply CSS rules based on device characteristics like viewport width, height, orientation, color scheme preference, and more. This tool provides preset queries for common use cases (mobile, tablet, desktop, dark mode, print, reduced motion) and a custom builder for creating complex conditions. You can set the media type (screen, print, all), add multiple feature conditions, and choose how to combine them (AND or OR). The generated query includes proper syntax with the @media rule and brackets, ready to paste into your CSS.

Why Use Media Query Generator?

  • Common presets for mobile, tablet, desktop, dark mode, and more
  • Support for all CSS media features including modern ones
  • AND/OR operators for combining multiple conditions
  • Reference table of common breakpoints for quick lookup

Common Use Cases

Responsive Layouts

Create breakpoint-based styles for different screen sizes.

Dark Mode Support

Generate prefers-color-scheme queries for dark mode styles.

Print Stylesheets

Write @media print queries for print-optimized styles.

Accessibility Features

Target reduced motion and contrast preferences for accessible designs.

Technical Guide

CSS media queries use the @media rule to conditionally apply styles. The syntax is @media [type] and (condition) { rules }. Media types include screen, print, and all. Media features test device capabilities: min-width/max-width for responsive breakpoints, orientation for landscape/portrait, prefers-color-scheme for dark/light mode, prefers-reduced-motion for animation sensitivity, hover for hover capability, and pointer for input precision. Multiple conditions are combined with and keyword for all conditions, or comma-separated for any condition. The not keyword negates a query. Modern features like prefers-color-scheme and prefers-reduced-motion enable progressive enhancement for user preferences. For mobile-first approach, use min-width queries. For desktop-first, use max-width. Combining both creates range queries like @media (min-width: 768px) and (max-width: 1023px).

Tips & Best Practices

  • 1
    Use mobile-first approach with min-width queries for better performance
  • 2
    Always include prefers-reduced-motion for accessibility
  • 3
    Test prefers-color-scheme for automatic dark mode support
  • 4
    Use range queries (min and max) for targeting specific device categories

Related Tools

Frequently Asked Questions

Q Should I use min-width or max-width?
min-width follows mobile-first (recommended). max-width follows desktop-first. Choose based on your design approach.
Q What breakpoints should I use?
Common breakpoints: 640px (mobile), 768px (tablet), 1024px (laptop), 1280px (desktop), 1536px (large desktop).
Q Can I combine multiple conditions?
Yes, use and to require all conditions, or comma to match any condition.
Q What is prefers-color-scheme?
It detects whether the user has set their OS to dark or light mode, allowing automatic theme switching.
Q How do I support reduced motion?
Use @media (prefers-reduced-motion: reduce) to disable or reduce animations for sensitive users.

About This Tool

Media Query Generator is a free online tool by FreeToolkit.ai. All processing happens directly in your browser — your data never leaves your device. No registration or installation required.