The height media feature targets the viewport’s vertical size. Adapt layouts for tall desktops, short laptop windows, and landscape phones with min-height and max-height queries.
01
@media
Media query.
02
min-height
Tall screens.
03
max-height
Short screens.
04
Viewport
Window height.
05
vs width
Vertical axis.
06
vs property
Query vs size.
Fundamentals
Introduction
Most responsive tutorials focus on width — stacking columns on narrow phones. The height media feature adds another axis: the viewport height, or how tall the browser window is.
A user on a wide but short window (split-screen laptop, landscape phone with keyboard open) may need compact headers and scrollable content. A tall viewport can support full-screen heroes and spacious vertical rhythm.
Definition and Usage
Write @media (min-height: 600px) or @media (max-height: 400px) to apply styles when the viewport meets your height condition. Values use length units such as px, em, rem, or viewport units like vh.
💡
Beginner Tip
Do not confuse this with the CSS height property, which sizes an element. The media feature checks the browser window height, not an individual box.
Foundation
📝 Syntax
Use min-height, max-height, or an exact height inside @media:
syntax.css
/* Viewport is at least 600px tall */@media(min-height:600px){/* Styles for tall viewports */}/* Viewport is at most 400px tall */@media(max-height:400px){/* Styles for short viewports */}/* Exact viewport height (rare) */@media(height:768px){/* Matches only at exactly 768px height */}
Feature Variants
min-height — Matches when viewport height is greater than or equal to the value (tall screens).
max-height — Matches when viewport height is less than or equal to the value (short screens).
height — Matches an exact viewport height; rarely used because few users hit one precise pixel height.
height Media Feature vs height Property
@media (min-height: 600px) Viewport query — “Is the browser window at least 600px tall?”
height: 600px; Element sizing — sets one box to exactly 600 pixels tall.
height vs width Media Features
@media (min-width: 48rem) Horizontal axis — phones vs tablets vs desktops by window width.
@media (min-height: 32rem) Vertical axis — short split windows vs tall full-screen viewports.
UI adapts when users resize vertically or use short viewports.
Compatibility
🖥 Browser Compatibility
The height, min-height, and max-height media features are supported in all modern browsers.
✓ Baseline · Universal support
Viewport height queries
Works in Chrome, Firefox, Safari, Edge, and Opera.
99%Global support
height media features99% supported
Bottom line: Height media queries are safe for production. Combine with width queries for complete responsive coverage.
Wrap Up
🎉 Conclusion
The height media feature lets you respond to viewport height with min-height, max-height, and exact height queries. It complements width-based breakpoints for truly flexible layouts.
Use it for full-viewport heroes on tall screens, compact UI on short windows, and combined width-and-height rules for large desktops. Always distinguish viewport height queries from the CSS height property on elements.
Use these points when writing height-based responsive CSS.
5
Core concepts
↑01
min-height
Tall screens.
Query
↓02
max-height
Short screens.
Query
VP03
Viewport
Window height.
Target
+W04
and width
Both axes.
Combine
🌐05
99% support
Universal.
Compat
❓ Frequently Asked Questions
The height media feature matches styles based on the viewport height — the visible height of the browser window. Use min-height, max-height, or an exact height value inside @media rules to adapt layouts when the screen is tall or short.
min-height applies styles when the viewport is at least the given height (tall screens). max-height applies styles when the viewport is at most the given height (short screens). Combine both to target specific height ranges.
The media feature queries the viewport height for conditional rules. The height property sets the height of an individual element. @media (min-height: 600px) checks the window; height: 600px sizes one box.
Use them for full-viewport heroes on tall screens, compact headers on short laptop windows, scrollable panels in landscape mobile, and layouts where vertical space matters more than width.
Yes. min-height, max-height, and height media features are supported in all modern browsers including Chrome, Firefox, Safari, Edge, and Opera.