The formula
rem = px ÷ root font size (16px by default)
em = px ÷ parent element's font size
pt = px × 0.75 (CSS defines 1in = 96px = 72pt)
% = px ÷ root font size × 100
Worked example
- 24px with a 16px root font size = 24 ÷ 16 = 1.5rem.
- Inside an element with a 20px font size, 24px = 1.2em.
- 24px = 18pt, and 150% of the root size.
- CSS: font-size: 1.5rem; /* 24px */
Why use rem instead of px?
The rem unit is relative to the root element's font size, which in every major browser defaults to 16px. Sizing text and spacing in rem means your design scales when users change their browser's default font size, an important accessibility setting for people with low vision. Pixel sizes ignore that setting in many browsers. WCAG success criterion 1.4.4 requires text to be resizable up to 200% without loss of content, and using rem for font sizes is one of the simplest ways to support it.
rem versus em
Both are relative units, but rem is always relative to the root font size, while em is relative to the font size of the element's parent, or of the element itself for properties other than font-size. That makes em compound: a 1.2em font inside another 1.2em element is 1.44 times the base size. Em is useful when something should scale with its component's text, such as padding on a button. Rem is more predictable for global typography and layout spacing. Enter a parent size to see the em equivalent.
The 62.5% trick
Some developers set html { font-size: 62.5%; } so that 1rem equals 10px, making conversions easy: 24px becomes 2.4rem. It respects the user's browser setting, since 62.5% of a larger default is still proportionally larger, but it requires resetting body text to 1.6rem and can confuse third-party components that assume a 16px root. Modern tooling, CSS custom properties and this calculator make the trick unnecessary for most projects. If you use it, set the root font size here to 10.
Points and print
CSS defines an absolute inch as 96 CSS pixels and 72 points, so 1pt is 1.333px and 12pt body text in a word processor is 16px on screen. Points are mainly useful in print stylesheets. CSS pixels themselves are reference pixels, not physical screen pixels: on high-density displays, one CSS pixel may be two or three device pixels. For printing images at the right resolution, use our DPI calculator, and for pixel density of screens, the screen size and PPI calculator.
Building a type scale
Instead of choosing font sizes one by one, many designers use a modular scale: each size is the previous one multiplied by a fixed ratio, such as 1.25 or the golden ratio, 1.618. This gives headings that feel harmonious and makes design decisions faster. Our typography scale calculator generates a full set of sizes in px and rem with CSS custom properties. For text colour, check accessibility with the WCAG contrast checker.
Quick reference
With a 16px root: 12px = 0.75rem, 14px = 0.875rem, 18px = 1.125rem, 20px = 1.25rem, 32px = 2rem and 48px = 3rem.
Media queries and spacing
Rem is also a good choice for breakpoints in media queries, which then respond to the user's font size as well as screen width; em in media queries behaves the same because it's based on the initial font size. For spacing, many design systems use a base unit such as 4px or 0.25rem and multiples of it, which keeps layouts consistent. Viewport units and clamp() can make text fluid between minimum and maximum sizes, for example font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem).