A tablet held upright is an awkward guest in most responsive designs. It is too wide for the phone layout, which stretches single columns into long ribbons. It is too narrow for the desktop layout, which squeezes sidebars and grids until they cramp. So it inherits one or the other and wears it badly. The fix is to stop lending it a layout and give it a query of its own.
That query has a specific shape: a width range with both ends set, plus an orientation condition, joined by "and". This guide builds it with the free Media Query Builder on Ovatly. It reads the result part by part, so you can see what each condition does.
Contents
- Quick answer
- Why portrait tablets need their own query
- The width band is a convention, not a standard
- Reading the output block part by part
- How to build it, step by step
- Worked example: from a phone query to a tablet portrait query
- Limitations and honest tradeoffs
- Common mistakes
- FAQs
- Conclusion
- References
Quick answer
To target tablets in portrait mode, set a minimum width and a maximum width. The query then describes a range rather than a threshold. Add the orientation condition set to portrait. Choose the media type screen. Let the conditions join with "and". In the Media Query Builder that is four fields; it validates the range and hands you the complete block, placeholder included.
Why portrait tablets need their own query
Orientation changes what fits. A tablet in portrait is tall and narrow: one comfortable reading column, stacked cards, a navigation that collapses. Rotate it to landscape and the same device becomes short and wide, with room for two columns and a sidebar. A layout designed for one shape is a compromise in the other. Width alone cannot tell you which shape you are in. A landscape tablet's width can resemble a small laptop window. Its portrait width sits near a large phone's.
That is why the orientation condition exists. It separates the held-upright case from everything else at a similar width. The portrait treatment applies only when the tablet is held that way. Landscape falls to the wider ranges.
The width band is a convention, not a standard
No standards body defines where a tablet begins and ends. The band most designs use runs from about 768px to about 1024px in CSS pixels. It is a convention. It is a habit formed because many tablets report widths inside it. The builder's presets embody common bands like this one.
Treat the band as a starting point, not a law. If your layout holds together at 800px but falls apart at 1000px, your tablet range should reflect your layout, not the convention. What matters is that both ends are set deliberately. Set a minimum that keeps phones out. Set a maximum that hands larger screens back to their own ranges.
Reading the output block part by part
The builder produces a complete block, and each part has a job:
@media screen and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
/* your CSS here */
}
@mediaopens the query; everything in the braces applies only when every condition holds.screenis the media type; the alternative, all, would include print as well.(min-width: 768px)is the floor of the range: narrower viewports (phones) are excluded.(max-width: 1024px)is the ceiling: wider viewports are left to the desktop ranges.(orientation: portrait)is the shape test: the viewport must be taller than it is wide.- The
andbetween them is literal: all three must be true at once, or none of the block applies. - The comment inside the braces marks where your own layout CSS goes.
How to build it, step by step
- Open the Media Query Builder and start from a tablet preset if one is close; otherwise enter the widths yourself.
- Set the media type to screen.
- Set the minimum width to the bottom of your tablet band, commonly 768px, and the maximum width to the top of it, commonly 1024px. Unlike a phone query, both ends get a value; an empty field means no limit on that side, which is not what a band is.
- Add the orientation condition and set it to portrait.
- Check the fields as a set; the builder flags a minimum above the maximum here instead of shipping a query that can never match.
- Copy the block into your stylesheet and replace the placeholder comment with your portrait layout rules. Test on a tablet in both orientations. Confirm the styles engage upright and release when rotated.
Worked example: from a phone query to a tablet portrait query
Start with the simplest query the builder makes. It has media type screen and a maximum width of 767px. The minimum is left empty. The output is:
@media screen and (max-width: 767px) {
/* your CSS here */
}
That is a threshold, not a band. Everything from the smallest phone up to 767px matches. That is right for phones and wrong for tablets. The tablet portrait query grows from it. The single maximum becomes a range. A minimum of 768px is added so the band starts exactly where the phone range ends. A new maximum of 1024px stops it before desktop territory. Then the orientation condition is added. The range alone would also catch the same tablets in landscape. It would catch any small desktop window in the band too. Three conditions, each removing a group you do not mean: phones below, desktops above, landscape holders beside. What is left is the portrait tablet, and only the portrait tablet.
Limitations and honest tradeoffs
The builder assembles the query and validates the fields. It does not write the layout CSS inside the block. It cannot test the result on your page or your devices. The widths it works in are CSS pixels, so a tablet's advertised physical resolution is not the number to type. The tablet band itself is a convention. Some devices will always sit near an edge. A very large phone in landscape or a small laptop window can fall inside your range. Only the orientation condition and your own testing will tell you whether that matters. Finally, a dedicated portrait query is one more range to maintain; a fluid layout that already adapts smoothly may not need it.
Common mistakes
- Setting only a maximum width. A phone-style threshold that swallows everything below it; a tablet band needs a minimum too.
- Forgetting the orientation condition. The width range alone also matches landscape tablets and resized desktop windows.
- Using orientation with no width range. Every portrait phone matches as well, which is rarely the intent.
- Leaving a gap at the boundary. If the phone range ends at 767px, the tablet band should start at 768px, not 769px.
- Typing the physical resolution. Breakpoints are CSS pixels; the spec sheet number puts the band in the wrong place.
- Copying the band as gospel. 768 to 1024 is a convention. Adjust it to where your layout changes character.
FAQs
What width range counts as a tablet? There is no official range. The widely used convention puts tablets between about 768px and about 1024px in CSS pixels, and the builder's presets embody common bands like this one. It is a starting point, not a standard, so adjust it if your layout strains at a different width.
Why add orientation if I already set a width range? Because the same tablet reports a different width when rotated, and the two shapes suit different layouts. A width range alone cannot separate an upright tablet from a landscape phone or a small laptop window. The orientation condition pins the query to the held-upright case.
Can I use the orientation condition on its own? You can, but it will match every portrait screen, including portrait phones, rarely what a tablet treatment is for. Pairing it with a minimum and maximum width keeps the query aimed at the tablet band only.
What goes inside the block the builder outputs? Your own CSS. The builder assembles the query with a placeholder comment inside the braces. The comment marks where your rules go. The builder also validates your fields. The layout styles themselves are yours to write.
Do these widths mean the screen's physical pixels? No. Media queries measure viewport CSS pixels, and high-density screens pack several physical pixels into each one. A tablet reports a smaller CSS width than its physical resolution, and that is the number your breakpoints should use.
Conclusion
A portrait tablet query is a range plus a shape. Minimum and maximum widths fence off the band. Orientation insists on upright. "and" holds all of it to account at once. Built from fields in the Media Query Builder, the range gets validated before it ships, and the block arrives complete, placeholder included. If your queries are already written and the layout is still breaking, see our companion guide on common media query mistakes that break responsive layouts. It works through the failures hiding in existing stylesheets. For more guides in this series, see our Website and Webmaster Tools guides.
References
- MDN Web Docs, on media queries, width ranges and the orientation media feature: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Media_queries/Using_media_queries
- web.dev (Google), on responsive design patterns for different screen shapes: https://web.dev/learn/design