CSS Unit Converter
CSS supports a dozen different length units - absolute ones like px, pt, in, and cm,
font-relative ones like em and rem, and viewport-relative ones like vw and vh - and
mixing them up is one of the most common sources of inconsistent spacing in a stylesheet.
This tool converts a value between any two CSS units and shows the same value expressed in
every supported unit at once, using the base font size and viewport dimensions you provide.
Absolute units
Absolute units are fixed relative to each other, independent of font size or screen. They all resolve to pixels through the same reference used by browsers (96px per inch):
Font-relative units
rem is always relative to the root (<html>) element's font size, while em is relative
to the current element's font size. This tool asks for a single base font size and uses it
for both, which is accurate whenever the element you're styling doesn't have its own font-size
override:
Viewport-relative units
vw and vh are percentages of the browser's viewport width and height, so converting them
needs the viewport size you're designing for:
How the conversion works
Every unit is first converted to a common base of pixels, then from pixels into the target unit:
How to use this tool
- Enter the numeric value you want to convert
- Choose the unit you're converting from and the unit you're converting to
- Set the base font size (defaults to the browser default of 16px) used for
em/rem - Set the viewport width and viewport height used for
vw/vh - Submit to see the converted value, plus a full table showing that same amount expressed in every supported unit
Worked example
Converting 24px to rem, with a base font size of 16px:
So font-size: 24px and font-size: 1.5rem produce the same rendered text size when the
root font size is 16px - which is why 1.5rem is the more common way to write that value in
a modern, accessibility-friendly stylesheet.