width, and its min-width/max-width variants, refers specifically to the browser's viewport width, the visible browsing area, not the physical screen's total resolution, which is why the exact same media query behaves identically whether a user is on a small physical phone screen or has simply resized a desktop browser window down to that same narrow width. height and its min-height/max-height variants work identically but target the viewport's vertical dimension instead, which is used less frequently in typical responsive design, since horizontal width is usually the more relevant constraint for reflowing a page's layout.
1Understanding Screen Dimensions
width, and its min-width/max-width variants, refers specifically to the browser's viewport width, the visible browsing area, not the physical screen's total resolution, which is why the exact same media query behaves identically whether a user is on a small physical phone screen or has simply resized a desktop browser window down to that same narrow width. height and its min-height/max-height variants work identically but target the viewport's vertical dimension instead, which is used less frequently in typical responsive design, since horizontal width is usually the more relevant constraint for reflowing a page's layout.
width in a media query always refers to the browser's viewport width, not the physical device's actual screen resolution — a narrow desktop browser window and a small phone screen at the exact same viewport width trigger the identical set of width-based media query styles.
@media (max-width: 480px) {
.container {
padding: 10px;
}
}2Practical Example
Here is a real-world application of Screen Dimensions showing how it is used in production CSS code.
@media (min-height: 800px) {
.hero {
min-height: 600px;
}
}3Best Practices
Follow these guidelines when working with Screen Dimensions:
1. Base responsive breakpoints on min-width/max-width viewport width, the far more commonly relevant dimension for reflowing layout, rather than height in most typical designs
2. Remember width-based media queries respond to the actual current browser viewport size, including a resized desktop window, not just a device's fixed physical screen resolution
3. Choose breakpoint values based on where your own specific content and layout actually needs to change, rather than blindly targeting specific named devices' exact screen widths
Tip: width in a media query always refers to the browser's viewport width, not the physical device's actual screen resolution — a narrow desktop browser window and a small phone screen at the exact same viewport width trigger the identical set of width-based media query styles.
@media (max-width: 480px) {
.container {
padding: 10px;
}
}