Recommended Free Tools
Use @media (orientation: portrait) to apply CSS when the relevant viewport is at least as tall as it is wide. It tests the viewport’s shape—not whether a phone or tablet is physically held upright—so a square viewport also matches portrait.
Write a portrait orientation media query
Put the styles that should apply in an @media rule with the portrait value:
/* Base layout applies unless a matching query overrides it. */
.cards {
display: flex;
flex-direction: row;
gap: 1rem;
}
@media (orientation: portrait) {
.cards {
flex-direction: column;
}
}
Here, the cards stack when the viewport is portrait or square; otherwise, they remain in a row. The selector and property should reflect the layout change you actually need. Orientation does not identify a particular device class or screen size. See the MDN orientation reference for the feature and example.
You can include a media type when useful: @media screen and (orientation: portrait) { ... }. The condition itself is (orientation: portrait). The corresponding value for a wide viewport is landscape.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
What portrait means to CSS
CSS evaluates orientation using the geometry of the viewport (or the page box in paged media). Portrait means its height is greater than or equal to its width; landscape means its width is greater than its height. Therefore, a square viewport matches portrait. This is the definition in the CSS Media Queries Level 5 draft.
The query does not read a device-orientation sensor. A browser window or iframe may have a shape that differs from the device display, and CSS uses the viewport relevant to the page or frame being styled.
Rank #2
Choose orientation, width, height, or aspect ratio
Use the condition that describes the constraint your layout responds to:
| Layout need | Condition | Why it fits |
|---|---|---|
| Switch behavior between tall-or-square and wide viewports | (orientation: portrait) or (orientation: landscape) |
Tests the portrait/landscape geometry category. |
| Change layout at a horizontal-space breakpoint | (min-width: ...) or (max-width: ...) |
Tests the available width directly. |
| Respond to limited vertical space | (min-height: ...) or (max-height: ...) |
Tests the available height directly. |
| Respond to a particular width-to-height proportion | (min-aspect-ratio: ...) or (max-aspect-ratio: ...) |
Tests the viewport’s proportion rather than just its orientation category; see MDN’s aspect-ratio reference. |
Do not use orientation as a synonym for “mobile.” A narrow desktop window can be portrait, while a phone or tablet can be landscape. If the real issue is whether content fits horizontally, use a width breakpoint; if it is the viewport’s proportions, use aspect ratio.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteRank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Why portrait styles may change when the keyboard opens
On some devices, opening the soft keyboard changes the available viewport dimensions enough to make it wider than tall. The browser can then match landscape rules even while the device remains physically upright. An iframe also evaluates orientation against its own viewport, not necessarily the surrounding page’s.
When a layout behaves unexpectedly, inspect the viewport whose CSS is being evaluated and test with the keyboard open. Check whether the viewport’s width has exceeded its height before changing the query.
Rank #4
Test the layout in a browser
- Identify the constraint. Decide whether the design depends on tall-versus-wide geometry, a specific width, a height limit, or a proportion.
- Apply the matching condition. Add an orientation, width, height, or aspect-ratio media query around only the styles that need to change.
- Resize and rotate. Check the layout in portrait and landscape shapes, including a square viewport if that boundary matters to the design.
- Check the actual viewport. For embedded content, test inside the iframe. On touch devices, test with the soft keyboard open if users can trigger it.
Orientation and aspect-ratio features are broadly available, but the references cited here do not provide a version-by-version compatibility matrix. Consult current compatibility data for a specific browser support requirement rather than assuming a particular minimum version.
Troubleshoot a portrait query that does not behave as expected
- The rule matches on a square viewport: that is expected; square counts as portrait because the height is equal to the width.
- The rule changes while the device stays upright: CSS follows viewport geometry, not physical rotation. A soft keyboard can change that geometry.
- The main page and embedded content disagree: the iframe has its own viewport, which determines the query result for styles inside it.
- The rule applies on a desktop window: orientation describes shape, not device type. A narrow window can satisfy portrait.
- The design breaks at a particular width: use a width condition instead of orientation if the actual requirement is a breakpoint.
- The design depends on a precise proportion: use an aspect-ratio condition when a simple portrait/landscape category is too broad.
Or skip the browser setup
If you need a screenshot of the result without setting up a browser capture workflow, ScreenshotNeo is a website screenshot API and MCP server. A single request can return an image or PDF; its documentation lists the request options.
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Before capture, it accepts consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




