CSS lets you set sizes in pixels, rem, em and points, and designers hand over pixels while developers prefer rem. The px to rem converter takes a size in pixels, the root font size and the parent font size to give the value in rem, em, points, percent of the root size and millimeters, and it converts a rem value back to pixels.
How the calculation works
- rem = pixels ÷ root font size. The rem unit is relative to the font size of the html element, which is 16 px in most browsers. A size of 24 px is 24 ÷ 16 = 1.5 rem.
- em = pixels ÷ the font size of the parent element. Unlike rem, em compounds when elements are nested, since each level multiplies the size.
- Points = pixels × 0.75, because CSS defines 1 inch as 96 pixels and 72 points, so 1 px = 0.75 pt. Millimeters = pixels × 25.4 ÷ 96.
- Share of the root size = pixels ÷ root size × 100. The last output goes the other way: rem value × root size gives pixels.
Example
With the default root size of 16 px, a size of 24 px is 24 ÷ 16 = 1.5 rem, or 150% of the root size. If the parent text is 20 px, it is 24 ÷ 20 = 1.2 em. It is 18 pt and about 6.35 mm on a screen at 96 dpi. In the other direction, 1.25 rem is 1.25 × 16 = 20 px.
Why it matters
Relative units make a page more accessible, since text and layout follow the size the reader has chosen. A quick conversion avoids mental arithmetic when you move a design from pixels to a flexible CSS, and it shows how a change in the root size affects every value.
Good to know
Remember that rem does not follow the font size of the parent, and em does. If a site sets the root size to something other than 16 px, enter that value. Media queries in em or rem also follow the user’s font size, which many accessibility guides recommend. The millimeter value is for 96 dpi CSS pixels and not the real size on a phone or a high-density screen.
Related tools
The aspect ratio calculator keeps the proportions of an image and the screen size calculator relates diagonal, width and height.