b2KIT

CSS Media Query Generator

Generate responsive CSS media queries for common breakpoints, devices, and screen orientations.

Tested tool guide Tested browser tools Checked August 16, 2026

What CSS Media Query Generator does and how it behaves

CSS Media Query Generator converts a chosen breakpoint, device preset, or screen orientation into a CSS @media rule ready for declarations. It saves you from manually arranging media-feature names, values, parentheses, and logical conditions. The main source of confusion is that device labels do not identify hardware. The generated rule tests properties such as viewport width and orientation, so any browser viewport satisfying those conditions can match, regardless of the device model that produced it.

How the result is produced

1

Breakpoint conditions

A width breakpoint becomes a condition such as min-width or max-width. A minimum-width condition begins matching when the viewport reaches the stated width in CSS pixels, while a maximum-width condition includes widths up to its stated boundary. If lower and upper limits are joined with and, the rule applies only when every listed condition is true.

2

Orientation conditions

Selecting an orientation adds either (orientation: portrait) or (orientation: landscape) to the media query. Portrait means the viewport height is at least its width; landscape means the viewport width is greater than its height. When orientation and width appear in one query joined by and, changing either viewport dimension can change whether the enclosed CSS applies.

Good uses

  • Generate a mobile-first min-width rule before adding the declarations that should take effect when a layout reaches a wider breakpoint.
  • Create a bounded viewport-width query for styles intended only between two layout breakpoints, such as a compact navigation arrangement used at intermediate widths.
  • Add an orientation condition for a component whose spacing or arrangement should change when the browser viewport becomes wider than it is tall.

Limits and checks

  • Treat named device and breakpoint presets as convenient dimension choices, not guaranteed device categories. Phones, tablets, desktop windows, embedded browsers, and resized panels can share the same CSS viewport width.
  • Check whether adjacent rules overlap at a boundary. Both min-width: 768px and max-width: 768px match at exactly 768 CSS pixels, and the normal CSS cascade then determines which competing declarations win.
  • Do not read orientation as a sensor report or a promise about physical rotation. Browser chrome, split-screen mode, an on-screen keyboard, and window resizing can alter viewport proportions without the hardware changing posture.

Common questions

Does a phone or tablet preset target only that kind of device?

No. A preset produces media conditions based on dimensions or orientation; it does not establish the manufacturer, model, input hardware, or operating system. A desktop browser window can match a phone-sized query, and a high-resolution phone may expose a CSS viewport unlike its physical pixel dimensions. Use the label as a breakpoint convenience, not device detection.

Can this generator create CSS container queries?

No. Its output is a media query, which evaluates characteristics of the browsing environment or viewport. Container queries use @container and evaluate an ancestor query container instead. If a component must respond to the space allocated by its parent rather than the viewport, a generated @media rule does not answer that requirement.

References and verification

The behavioral notes were checked against the browser implementation. Standards and primary references below define the relevant format, formula, or platform behavior.

Related Tools