How to convert CSS pixels to rem
rem = px × (1) ÷ (root font size in px)
Convert px into CSS reference pixels, then divide by the pixel size of rem. The reference table uses 16 px for both element and root font sizes. Examples state any different context. For em in a font-size declaration, use the parent’s computed font size; for other properties, use the element’s computed font size.
Worked examples
16 px ≈ 1 rem
16 × 1 ÷ 16 ≈ 1
Font basis for this example: element 16 px; root 16 px.
24 px ≈ 1.2 rem
24 × 1 ÷ 20 ≈ 1.2
Font basis for this example: element 16 px; root 20 px.
Frequently asked questions
Which font or display assumption applies?
em and rem depend on the specified font context. CSS absolute units have fixed relationships to reference pixels, which do not necessarily equal physical display pixels.