Every responsive layout eventually breaks. The navigation that looked fine on your monitor wraps into two lines on a tablet, and the three column grid that suited a desktop becomes an unreadable squeeze on a phone. Media queries are how CSS answers that: different rules for wide and narrow viewports, switched at widths you choose, called breakpoints.

Choosing those widths feels like it should have an official answer, a standard table of phone, tablet and desktop sizes. It does not. What exists is a set of conventions most of the web has settled on. The free Media Query Builder on Ovatly assembles those breakpoints into complete @media blocks: pick a device preset or enter exact pixel widths, add an orientation condition if you need one, and copy the block into your stylesheet.

Contents

  • Quick answer
  • The honest truth about breakpoint numbers
  • A conventional breakpoint table
  • CSS pixels are not physical pixels
  • How the conditions combine
  • How to build a media query, step by step
  • Worked example: phones only, then a tablet range
  • Limitations and honest tradeoffs
  • Common mistakes
  • FAQs
  • Conclusion
  • References

Quick answer

The conventional split is phones up to 767 px wide, tablets from 768 to 1023 px, and desktops from 1024 px up, all in viewport CSS pixels. These numbers are widely used conventions, not official standards: no standards body defines phone or tablet widths. To use them, open the Media Query Builder, choose a device preset or type your own minimum and maximum widths, pick the media type and an orientation if needed, and copy the complete @media block it produces. Replace the placeholder comment inside the block with your CSS.

The honest truth about breakpoint numbers

Search for breakpoints and you will find a dozen tables that disagree with each other slightly. That disagreement is the tell: the numbers are conventions gathered from common device sizes, not measurements handed down by a standards body. CSS itself defines how media queries work, the syntax and the conditions. It does not define which widths count as a phone.

The builder treats its presets the same way, and labels them as the conventions they are. A preset is a starting point that matches what most sites use. Where your own layout breaks is the final authority, and the custom fields exist so you can encode your layout's real breakpoints instead.

A conventional breakpoint table

Viewport widthCommon labelQuery shape
Up to 767 pxPhoneMaximum width only
768 to 1023 pxTabletMinimum and maximum width
1024 px and upDesktopMinimum width only
1280 px and upLarge desktopMinimum width only

Read the table as ranges of viewport width, not as device detections. A phone held sideways can land in the tablet range, and a narrow desktop window can land in the phone range. That is correct behaviour: the query responds to the space your layout actually has, which is what your CSS needs to know. Heights work the same way when you need them, with minimum and maximum height fields, and an empty field on either side simply means no limit there.

CSS pixels are not physical pixels

One confusion causes more broken queries than any other. Media query widths are the viewport's CSS pixels, and on high-density screens those differ from the device's physical resolution. A phone may carry a physical screen well over 1000 px wide while reporting a viewport a fraction of that in CSS pixels, because the browser scales rendering to keep text readable.

This is why testing a query against a spec sheet's resolution numbers misleads you. Test against the viewport width the browser reports, which is the number the query sees.

How the conditions combine

A media query block can carry several conditions at once: a media type, a minimum width, a maximum width, height limits and an orientation. The builder joins them with and, so every condition must be true for the block to apply. A tablet landscape query asks for a width inside the tablet range and the landscape orientation at once; a portrait tablet falls through to another block or to your base styles.

The media type is chosen first. Screen targets screens, which is what responsive layout rules almost always intend; all covers every medium. Leaving a field empty is meaningful too: no maximum means the query runs from the minimum upward without a ceiling, and no minimum means it runs from the smallest viewport up to the maximum.

How to build a media query, step by step

  1. Open the Media Query Builder. Optionally choose a device preset to fill in typical widths.
  2. Adjust the minimum and maximum width or height in pixels to the range you want. Leave a field empty for no limit on that side.
  3. Choose the media type, and add an orientation condition if the rules should only apply in portrait or landscape.
  4. Check the block the builder produces. It validates the obvious mistakes, such as a minimum width larger than the maximum.
  5. Copy the @media block into your stylesheet and replace the placeholder comment inside it with your CSS.

Worked example: phones only, then a tablet range

Start with styles that should apply to small screens only. Choose the media type screen and set a maximum width of 767 px, with no minimum. The builder produces:

@media screen and (max-width: 767px) {
  /* your CSS here */
}

Every viewport of 767 CSS pixels or less gets the rules inside; anything wider ignores the block.

Now the tablet range. Set a minimum width of 768 px and a maximum of 1023 px, media type screen. Both conditions appear in the query, joined by and, so the block opens with @media screen and (min-width: 768px) and (max-width: 1023px). The two blocks cover the table's phone and tablet conventions, and a desktop block with a minimum of 1024 px completes the set.

Limitations and honest tradeoffs

The builder assembles the query; it does not design the layout. It cannot know where your particular design breaks, and the presets being conventions means a layout with unusual columns or long navigation labels may need different numbers. It also does not test the result: the block it produces is syntactically complete, but whether the CSS you place inside it fixes the layout only your own testing on real viewport widths can confirm.

Breakpoints also age. Device sizes drift, another reason the conventions are a starting point rather than a contract. The custom width fields are there for the day the table stops matching your audience.

Common mistakes

  • Setting a minimum larger than the maximum. The query can never match. The builder flags this, so fix it there rather than debugging a silent stylesheet.
  • Designing against physical resolution. Queries see CSS pixels. A high-density phone reports a modest viewport width, and your phone block will apply there.
  • Shipping the placeholder comment. The generated block contains a comment marking where your CSS goes. Replace it; a block with only the comment inside does nothing.
  • Aiming at devices instead of widths. A query cannot know what hardware it runs on, only how wide the viewport is. Write ranges, not device names.

FAQs

Are these breakpoint widths official standards? No. No standards body defines phone or tablet widths. The presets in the builder are widely used conventions gathered from common device sizes, and the builder labels them as conventions. Treat them as a practical starting point, not a rule.

Can I combine a width range with an orientation condition? Yes. Set the width range and pick portrait or landscape; the conditions are combined with 'and', so all of them must be true for the block to apply.

Why does my media query never match? Check for a minimum width larger than the maximum, which the builder flags. Also remember that widths are the viewport's CSS pixels, which differ from a device's physical resolution on high-density screens.

What happens if I leave a width field empty? An empty field means no limit on that side. A query with only a maximum width applies to every viewport up to that width, and one with only a minimum applies to everything above it.

Does the builder write my CSS rules for me? No. It produces the complete @media block with a placeholder comment inside. You replace that comment with your own CSS, which keeps the query correct while the design decisions stay yours.

Conclusion

Breakpoints are conventions, and knowing that makes you better at using them: take the common ranges as a starting point, adjust them to where your layout actually breaks, and let the Media Query Builder handle the syntax so the numbers are the only thing you think about. The same paste-and-check approach covers how a page describes itself to search engines and social apps, in our guide to checking the meta tags on any web page. Both live in our Website and Webmaster Tools guides, which pair each technique with the free tool that performs it.

References