px, rem and em: why 24 px is 1.5 rem and nested em keeps growing

A converter only gives the right number if you know which size each unit is measured against. We converted the same values with Apps24 using its defaults and a changed root size, and worked out nested em by hand.

Input and result

24pxroot 16px1.5rem
24pxroot 10px2.4rem
1.25em × 1.25emnested1.5625
360pxviewport 1440px25vw
12pt96 ÷ 7216px

What the result means

With a 16 px root, 24 px is 24 ÷ 16 = 1.5 rem; with a 10 px root the same 24 px is 2.4 rem. rem always uses the root, but em uses the font size of the element itself, so a 1.25 em box inside another 1.25 em box is 1.25 × 1.25 = 1.5625 times the base size. At a 1440 px viewport, 360 px is 25 vw, and 12 pt equals 16 px because 1 pt is 96 ÷ 72 CSS px.

What to do next

1. Enter your real root font size and viewport before converting. 2. Use rem for spacing and type that should follow the reader's text-size setting. 3. Use em only when a component should scale with its own text, and avoid deep nesting. 4. Confirm the result in the browser developer tools, which show the computed pixel value.

Use the tool

Limits and test conditions

Physical units (in, cm, mm, pt) are fixed fractions of 96 CSS px and do not guarantee real-world length on a screen or printout. vw can include the scrollbar width, and vh changes with mobile address bars; dvh, svh and lvh are not converted. Values are mathematical conversions, not measurements of your page.

References

Apps24 checks examples against the implementation and regression tests. Browser experiments state their conditions; they do not certify every device. Report an error with the page URL, input, expected result and browser. Never send passwords, private documents or personal data.