The Short Answer
For most web development, your screen's physical DPI doesn't matter. Web browsers use CSS pixels (logical units) that automatically adapt to different pixel densities. A 300px wide element takes the same visual percentage of screen space on a 96 PPI monitor and a 220 PPI Retina display.
Why DPI Is Mostly Irrelevant
CSS Pixels vs Physical Pixels
Browsers work with CSS pixels (also called device-independent pixels or logical pixels), not physical screen pixels. These are abstract units that scale based on the device pixel ratio.
Example:
- Standard display (1x): 1 CSS pixel = 1 physical pixel
- Retina display (2x): 1 CSS pixel = 4 physical pixels (2×2)
- High-density phone (3x): 1 CSS pixel = 9 physical pixels (3×3)
Responsive Design Independence
Modern CSS uses relative units that don't care about physical DPI:
- % — Percentage of parent element
- em/rem — Relative to font size
- vw/vh — Percentage of viewport
- fr — Fraction of available space (Grid)
These units adapt to any screen size and density without DPI awareness.
When DPI DOES Matter
Images and Asset Delivery
While layout doesn't care about DPI, image sharpness does. High-DPI displays need higher resolution images to avoid blurriness. Use responsive images:
<img src="logo.png"
srcset="logo@2x.png 2x, logo@3x.png 3x"
alt="Logo">
The browser automatically selects the appropriate image based on device pixel ratio.
Canvas and WebGL Applications
Canvas elements need manual DPI handling for crisp rendering:
const dpr = window.devicePixelRatio || 1;
canvas.width = 800 * dpr;
canvas.height = 600 * dpr;
ctx.scale(dpr, dpr);
Physical Measurement Tools
If you're building a ruler, measurement tool, or design app that needs real-world dimensions, you must calculate actual screen DPI. Use our DPI Calculator as reference.
Device Pixel Ratio
The key metric for web developers is device pixel ratio, accessible via JavaScript:
const dpr = window.devicePixelRatio;
console.log(dpr); // 1, 1.5, 2, 3, etc.
Common values:
- 1: Standard displays
- 1.5: Some Windows laptops at 150% scaling
- 2: Retina MacBooks, most high-end phones
- 3: iPhone Plus models, high-end Android
Media Queries and DPI
CSS media queries can target pixel density, but usually shouldn't:
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
/* Styles for high-DPI displays */
}
Instead, use responsive images and let the browser handle it automatically.
Performance Considerations
High-DPI screens have 4x or 9x more pixels to render. This impacts:
- GPU/CPU load for animations
- Memory usage for large images
- Data transfer for image downloads
Optimize by serving appropriate image resolutions based on device capabilities.
Conclusion
For typical web development—layouts, typography, spacing, responsive design—screen DPI is handled automatically by browsers. Focus on CSS pixels and responsive techniques. Only worry about actual DPI when building measurement tools, high-fidelity canvas apps, or optimizing image delivery.