๐Ÿ‹
Menu
How-To Beginner 1 min read 218 words

How to Create Retina-Ready Images for High-DPI Displays

Modern displays have 2x or 3x pixel density, making standard images appear blurry. Learn how to generate and serve crisp images for high-DPI screens efficiently.

The High-DPI Challenge

A Retina display packs twice the pixels into the same physical space. A 100x100 CSS-pixel image actually occupies 200x200 device pixels on a 2x display. If you only provide a 100x100 image, the browser upscales it, resulting in visible blur.

The srcset Solution

HTML's srcset attribute lets you provide multiple image sizes, allowing the browser to choose the best one:

Description

The browser downloads only the image matching the device's pixel ratio, saving bandwidth on standard displays.

Width Descriptors for Responsive Images

For responsive layouts where image display size varies, width descriptors combined with the sizes attribute provide better control:

Description

Image Generation Workflow

Start with the highest resolution source and generate smaller variants. Never upscale โ€” always scale down. For photographic content, generate 1x, 2x, and 3x versions. For icons and UI elements, use SVG instead, which scales infinitely without quality loss.

Performance Tradeoff

3x images are 9 times the pixel area of 1x images. Use aggressive compression for high-DPI images โ€” the extra pixels compensate for compression artifacts, allowing lower quality settings (60-70% for JPEG) while still appearing sharp on high-DPI screens.

Ferramentas relacionadas

Formatos relacionados

Guias relacionados