Course contentsShow
← Web Development
Lesson 165 of 2,9823. CSS FundamentalsFree lesson

Resolution Units: dpi, dpcm, dppx

Understand resolution units for media queries targeting different screen pixel densities.

Resolution Units: dpi, dpcm, dppx

You'll learn how to use resolution units in CSS to target devices with different screen pixel densities.

What Are Resolution Units?

Resolution units describe how densely pixels are packed on a screen. Think of it like comparing a standard TV to a high-definition TV of the same size — the HD screen has more pixels crammed into the same space, making images sharper.

In CSS, you use resolution units primarily in media queries to detect whether a user has a standard screen or a high-density "retina" display.

The Three Resolution Units

dpi — Dots per inch. This is familiar from printing but works in CSS for screen density. 96dpi is considered standard screen resolution.

dpcm — Dots per centimeter. Same concept as dpi, just using metric units. Less common in practice.

dppx — Dots per pixel unit (also written as x). This is the most intuitive for web developers. A value of 1dppx means standard density, 2dppx means twice as many physical pixels per CSS pixel (like retina displays).

How They Work

/* Target standard screens */
@media (resolution: 96dpi) {
  /* Styles for normal displays */
}

/* Target high-density screens (retina) */
@media (min-resolution: 2dppx) {
  /* Serve higher quality images here */
}

/* Using dpcm */
@media (min-resolution: 118dpcm) {
  /* Approximately equivalent to 2dppx */
}

These units help you serve appropriate image quality — standard images for regular screens, sharper images for retina displays — without wasting bandwidth.

Key Takeaway: Resolution units (dpi, dpcm, dppx) let you detect screen pixel density in media queries, most commonly using dppx to optimize images for high-density displays.