CKTIS / CSS
dppx — resolution unit
The dppx unit describes the number of dots per CSS pixel. It belongs to the <resolution> type, not to length units; 1dppx equals 96dpi.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
<number>dppxdppx means dots per CSS px and belongs to the <resolution> type. For example, 2dppx is a scalar density of two dots per CSS pixel, not a count of two dots across its area. It does not imply that the density is the same on both axes. For devices with non-square pixels, the resolution media feature reports the vertical density. dppx is not a length unit, so it cannot replace px in the width property.
Write the number immediately before the unit, for example 1.5dppx. Negative values are invalid. The conversion is 1dppx = 96dpi, and x is an alias for dppx.
In @media (min-resolution: 2dppx), the rules apply at and above the 2dppx threshold. The resolution feature accounts for page zoom, so it should not be treated solely as a fixed hardware characteristic. Using dppx does not itself increase image resolution.
When resolution applies to the medium and the browser supports the query syntax used here, the example sets --density on the document root to below-threshold below the threshold and at-least-two at or above it. The script determines the expected value using the equivalent (min-resolution: 192dpi) query in the same environment, so the comparison evaluates to true without requiring a particular device scale or page zoom.
On nonvisual media where resolution does not apply, neither stylesheet query matches and --density is left unset. The script's query also does not match, so the script still expects below-threshold. The value it reads is an empty string, so the comparison evaluates to false.
Examples
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Resolution media queries in dppx</title>
<style>
@media (resolution < 2dppx) {
:root { --density: below-threshold; }
}
@media (min-resolution: 2dppx) {
:root { --density: at-least-two; }
}
</style>
</head>
<body>
<p>A resolution query sets the root custom property at the 2dppx threshold.</p>
<script>
// 1dppx equals 96dpi, so 2dppx equals 192dpi.
const expected = matchMedia('(min-resolution: 192dpi)').matches
? 'at-least-two'
: 'below-threshold';
const actual = getComputedStyle(document.documentElement)
.getPropertyValue('--density').trim();
console.log(`2dppx custom property matches the 192dpi threshold: ${actual === expected}`);
</script>
</body>
</html>Result
2dppx custom property matches the 192dpi threshold: true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.