Understanding Pixel Density and Device-Pixel-Ratio in CSS Breakpoints
Pixel density, measured by the device-pixel-ratio (DPR), affects how CSS breakpoints behave on high-resolution screens. Devices with higher pixel densities (like Retina displays) contain more physical pixels per CSS pixel, which can influence how layouts and images appear even when breakpoints are defined using standard CSS units.
High-DPI screens display more pixels in the same physical space, making content appear sharper but potentially smaller.
Breakpoints defined in CSS use logical pixels, not physical pixels — ensuring consistent layout behavior across devices.
Media queries can include resolution or device-pixel-ratio conditions to serve high-resolution assets (e.g., retina images).
Designers often use srcset or CSS image-set() to load appropriately scaled images for different DPR values.
In this example, the media query detects devices with a device-pixel-ratio of 2 or higher (such as Retina displays) and loads a higher-resolution image to maintain visual clarity. However, breakpoints themselves still rely on logical pixels, ensuring layout consistency across different pixel densities.