What Is a CSS Media Query?

CSS media queries are conditional rules that apply styles only when specific criteria are met — most commonly screen width. They're the foundation of responsive web design, letting a single codebase adapt to phones, tablets, laptops, and desktops. This tool generates media query syntax with device presets, breakpoint visualizer, and framework-specific breakpoints for Bootstrap, Tailwind, and Material UI.

Mobile-First vs Desktop-First

Mobile-first (min-width) — start with styles for the smallest screen, then add complexity with min-width queries. This is the modern standard because base CSS is lighter and you progressively enhance. Desktop-first (max-width) — start with desktop styles and override downward. Still used in legacy codebases but produces heavier base CSS.

How to Use This CSS Media Query Generator

  1. Select the target devices — Choose which screen sizes you're targeting — mobile, tablet, laptop, desktop, or wide screen.
  2. Set breakpoint values — Enter your breakpoint widths in pixels. The tool suggests common values: 480, 768, 1024, 1200, and 1440px.
  3. Choose the strategy — Select mobile-first (min-width) or desktop-first (max-width) media queries.
  4. Add your CSS rules — Enter the CSS properties that should change at each breakpoint.
  5. Copy the media queries — Grab the complete @media blocks, ready to paste into your stylesheet.

Tips and Best Practices

Frequently Asked Questions

What is a CSS media query?
Conditional CSS that applies when screen conditions are met. @media (min-width: 768px) applies styles above 768px. The foundation of responsive design.
What are standard breakpoints?
640px (phones), 768px (tablets), 1024px (laptops), 1280px (desktops), 1536px (large screens). But design breakpoints around your content, not devices.
min-width or max-width?
Mobile-first uses min-width (build up from small). Desktop-first uses max-width (scale down). Mobile-first is the modern standard — lighter base CSS, progressive enhancement.
What is a CSS media query?+
A media query is a CSS technique that applies styles conditionally based on device characteristics — primarily viewport width. The syntax @media (min-width: 768px) { ... } applies enclosed styles only when the viewport is 768px or wider. Media queries are the foundation of responsive web design.
What are the standard responsive breakpoints?+
Common breakpoints are: 480px (small mobile), 768px (tablet/large mobile), 1024px (laptop/tablet landscape), 1200px (desktop), and 1440px (large desktop). These are guidelines, not rules — set breakpoints where your content needs them, not at arbitrary device widths.
What is mobile-first vs desktop-first CSS?+
Mobile-first starts with mobile styles as defaults and adds complexity with min-width queries as the screen grows. Desktop-first starts with desktop styles and removes features with max-width queries for smaller screens. Mobile-first is the industry standard because it produces simpler code and loads fewer styles on bandwidth-constrained mobile devices.

📖 Learn More

Related Article CSS Media Queries & Breakpoints Guide →

Built by Derek Giordano · Part of Ultimate Design Tools

Privacy Policy · Terms of Service