Viewport Calculator
Reference viewport dimensions for responsive design
Understanding Viewports
The viewport is the visible area of a web page or app on a device. For responsive design, we work with CSS pixels (viewport dimensions) rather than physical pixels.
CSS Pixels vs Physical Pixels
Modern devices use high-density displays where one CSS pixel corresponds to multiple physical pixels:
Physical Pixels = CSS Pixels × Device Pixel RatioExample: 390px × 3 = 1170 physical pixels
Device Pixel Ratio (DPR)
DPR defines how many physical pixels make up one CSS pixel:
| DPR | Quality | Examples |
|---|---|---|
| 1.0x | Standard | Older monitors, basic displays |
| 2.0x | Retina | Most iPhones, MacBooks, mid-range Android |
| 3.0x | Retina HD | iPhone Plus/Pro models, high-end Android |
| 3.5-4x | Ultra HD | Premium Android flagships |
Common Breakpoints
Based on device viewport data, here are recommended CSS breakpoints:
Mobile-First Approach
/* Extra small devices (phones, less than 576px) */
/* Default styles, no media query */
/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) { ... }
/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) { ... }
/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) { ... }
/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) { ... }
/* XXL devices (larger desktops, 1400px and up) */
@media (min-width: 1400px) { ... }
Common Framework Breakpoints
| Framework | Breakpoints |
|---|---|
| Bootstrap 5 | 576px, 768px, 992px, 1200px, 1400px |
| Tailwind CSS | 640px, 768px, 1024px, 1280px, 1536px |
| Material Design | 600px, 960px, 1280px, 1920px |
| Foundation | 640px, 1024px, 1200px, 1440px |
Viewport Meta Tag
The viewport meta tag controls how the browser renders your page on mobile devices:
Standard Configuration
<meta name="viewport"
content="width=device-width,
initial-scale=1,
maximum-scale=5,
user-scalable=yes">
Viewport Properties
| Property | Description | Recommended Value |
|---|---|---|
| width | Viewport width | device-width |
| initial-scale | Initial zoom level | 1 (100%) |
| maximum-scale | Maximum zoom level | 5 (for accessibility) |
| user-scalable | Can user zoom? | yes (for accessibility) |
| viewport-fit | How to fill viewport | cover (for notched devices) |
Responsive Design Strategies
1. Fluid Layouts
Use percentage-based widths that adapt to viewport:
.container {
width: 100%;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
}
2. Flexible Images
img {
max-width: 100%;
height: auto;
}
3. CSS Grid & Flexbox
/* Responsive grid */
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
}
4. Container Queries (Modern)
.card {
container-type: inline-size;
}
@container (min-width: 400px) {
.card-content {
display: flex;
}
}
Testing Viewports
Browser DevTools
- Chrome: Device Mode (Cmd/Ctrl + Shift + M)
- Firefox: Responsive Design Mode (Cmd/Ctrl + Opt/Alt + M)
- Safari: Enter Responsive Design Mode
Testing Tools
- BrowserStack: Test on real devices
- LambdaTest: Cross-browser testing
- Responsively: Open-source testing tool
- Physical Devices: Always test on real hardware
Best Practices
Mobile-First Design
- Start with mobile styles as the default
- Use min-width media queries to add complexity
- Optimize for touch interactions
- Prioritize content for small screens
Content Considerations
- Prioritize: Show most important content first
- Readable Text: 16px minimum font size on mobile
- Touch Targets: Minimum 44×44px tap areas
- Whitespace: Use padding generously on small screens
Performance
- Use responsive images with srcset
- Lazy load images below the fold
- Minimize CSS and JavaScript
- Test on real mobile networks
Common Viewport Scenarios
Portrait vs Landscape
/* Portrait orientation */
@media (orientation: portrait) {
.sidebar { display: none; }
}
/* Landscape orientation */
@media (orientation: landscape) {
.sidebar { display: block; }
}
High-DPI Displays
/* Retina displays */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
.logo {
background-image: url('logo@2x.png');
background-size: 100px 50px;
}
}
Dark Mode
@media (prefers-color-scheme: dark) {
body {
background: #000;
color: #fff;
}
}
Common Mistakes
- Not setting viewport meta tag (page will be zoomed out on mobile)
- Disabling zoom (accessibility issue)
- Using fixed widths instead of responsive units
- Not testing on real devices
- Ignoring landscape orientation
- Too many breakpoints (keep it simple)
- Designing for specific devices instead of flexible ranges
Common Viewports
Mobile (Portrait)
- 320px: iPhone SE, small phones
- 375px: iPhone 8, iPhone SE (2020)
- 390px: iPhone 14
- 414px: iPhone Plus models
Tablet
- 768px: iPad Mini, small tablets
- 810px: iPad (10.2")
- 1024px: iPad Pro 12.9"
Desktop
- 1366px: Common laptop
- 1920px: Full HD
- 2560px: 2K displays
Quick Tips
- Design for content, not devices
- Test at every breakpoint
- Use relative units (rem, em, %)
- Mobile-first approach
- Keep breakpoints simple
- Always include viewport meta
- Don't disable zoom