GoWin Tools
Tools
← px to rem Converter

px to rem Converter Β· 5 min read

The Pixel Lie: Why CSS Pixels Are Not Screen Pixels

When you write 16px in CSS, you are not specifying 16 physical pixels on the screen. The CSS pixel is a virtual unit β€” and understanding the difference is essential for designing screens across all device densities.

Two Meanings of Pixel

The word "pixel" has two distinct meanings in modern web development, and confusing them leads to real design problems:

  • Physical pixel (device pixel): An actual dot of light on the display panel. An iPhone 15 has 2,556 Γ— 1,179 physical pixels. A 4K monitor has 3,840 Γ— 2,160 physical pixels.
  • CSS pixel (reference pixel): A virtual unit defined by the W3C CSS specification, intended to represent approximately 1/96th of an inch at a comfortable viewing distance. This is the pixel you write in CSS.

The relationship between CSS pixels and physical pixels is determined by the device pixel ratio (DPR). On a display with DPR=2 (a "2x" or "Retina" display), one CSS pixel corresponds to 2Γ—2 = 4 physical pixels. On a DPR=3 display (common on high-end Android phones), one CSS pixel corresponds to 3Γ—3 = 9 physical pixels.

The Reference Pixel: W3C's Definition

The W3C CSS specification defines the CSS pixel as a "reference pixel" β€” specifically, the visual angle of one pixel on a device with a pixel density of 96 dpi at arm's length (approximately 28 inches). This produces a pixel size of approximately 0.265 mm or 1/96 inch.

The 96 dpi standard came from Windows 95/98, which used 96 dpi as its standard display density, calibrated for the monitors of that era (typically 14–15 inch CRT monitors with 640Γ—480 or 800Γ—600 pixel counts, usually operated at about 28 inches viewing distance). When CSS1 defined the px unit in 1996, it was essentially defining it to match the then-standard Windows display.

The specification says that for low-density displays (below 200 dpi), 1 CSS px = 1 device pixel. For high-density displays, the browser uses a device pixel ratio to scale appropriately. The result: CSS pixels are an abstraction layer over physical pixels, designed to produce consistent visual size across different display densities.

The iPhone That Changed Everything (2010)

The concept of device pixel ratio became critical in 2010 when Apple introduced the iPhone 4 with its Retina display β€” a screen with 326 pixels per inch, exactly double the previous iPhone's 163 ppi. Apple designed the Retina display to have exactly twice the physical pixels in each dimension (960Γ—640 instead of 480Γ—320).

To maintain backward compatibility with existing websites β€” which specified pixel sizes in CSS and expected them to map to device pixels β€” Apple defined a device pixel ratio of 2. The iPhone 4's browser reported a screen width of 320 CSS pixels (the same as the iPhone 3GS) despite having 640 physical pixels. Every CSS pixel rendered as a 2Γ—2 block of physical pixels, making text and images appear sharper without breaking any existing CSS.

This was a brilliant compatibility solution: existing websites worked, and the Retina display's extra pixels were used to render higher-quality text and graphics. But it established a permanent architectural division between CSS pixels and physical pixels that every web developer working with high-density displays must understand.

Device Pixel Ratios in the Wild

DevicePhysical WidthCSS WidthDPR
iPhone 3GS480px480px1.0
iPhone 4/4S (Retina)640px320px2.0
iPhone 15 Pro1179px393px3.0
Samsung Galaxy S241080px360px3.0
27" iMac (5K)5120px2560px2.0
Standard 1080p monitor1920px1920px1.0
4K monitor at 100% scale3840px3840px1.0
4K monitor at 200% scale3840px1920px2.0

The Viewport Meta Tag

Another layer of complication: early mobile browsers handled the pixel mismatch by zooming out. Mobile Safari on the original iPhone would render a desktop website at 980 CSS pixels wide (a typical desktop layout width) and scale it to fit the 320px CSS screen, making everything tiny. Users were expected to pinch-zoom to read content.

The <meta name="viewport" content="width=device-width, initial-scale=1"> tag was introduced to address this. It instructs the browser to set the viewport width to the device's CSS width (rather than a simulated desktop width) and not to zoom. Without this tag, responsive designs behave unpredictably on mobile β€” the browser may apply its own scaling on top of the DPR scaling.

Why This Matters for px and rem

Understanding the CSS pixel lie is directly relevant to the px vs. rem debate:

When you write font-size: 16px, you are specifying 16 CSS pixels β€” which will appear as 32 physical pixels on a DPR=2 display, or 48 physical pixels on a DPR=3 display. The browser handles the DPR scaling automatically; your CSS works consistently across display densities.

When you write font-size: 1rem, you are specifying a size relative to the root element's font size (typically 16px by browser default). This means the actual CSS pixel size depends on the user's font preferences β€” if they have increased their browser's default font size to 20px, 1rem = 20px for them. This user-controlled scaling is the primary accessibility advantage of rem over px.

Neither px nor rem are physical screen measurements β€” they are both abstractions. But rem adds a second layer of abstraction (relative to user preference) that px lacks. That additional layer is what makes rem preferable for accessible typography.

Convert px to rem β†’

References

  1. W3C. (2021). CSS Values and Units Module Level 3: Physical Units. W3C.
  2. Apple Inc. (2010). iPhone 4 Technical Specifications. apple.com.
  3. W3C. (2011). CSS Device Adaptation. W3C Working Draft.
  4. Viewport meta tag specification. (2010). Safari Web Content Guide. Apple.
  5. Marcotte, E. (2010). Responsive Web Design. A List Apart, Issue 306.