Does DPI Matter for Web Design?

Understanding when screen pixel density matters and when it doesn't

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:

Responsive Design Independence

Modern CSS uses relative units that don't care about physical DPI:

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:

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:

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.