Skip to content
Design & colour

CSS Unit Converter

Convert between every CSS length unit with a configurable root and parent size, then build a modular type scale from a base size and a ratio.

Convert

rem is measured against the root; em and % against the parent — which is why em compounds when elements are nested.

  • px — Absolute pixels24px
  • rem — Relative to the root font size1.5rem
  • em — Relative to the parent — compounds when nested1.5em
  • % — Relative to the parent150%
  • pt — Points, for print18pt
  • pc 1.5pc
  • in 0.25in
  • cm 0.635cm
  • mm 6.35mm

Type scale

  • xs10.2px · 0.640rem
  • sm12.8px · 0.800rem
  • base16.0px · 1.000rem
  • lg20.0px · 1.250rem
  • xl25.0px · 1.563rem
  • 2xl31.3px · 1.953rem
  • 3xl39.1px · 2.441rem
  • 4xl48.8px · 3.052rem
  • 5xl61.0px · 3.815rem

As custom properties

About the CSS Unit Converter

The unit question that actually matters is rem versus em, and the difference is what each is measured against. A rem is relative to the root font size and nothing else. An em is relative to the font size of its own parent — which means em compounds. Nest three elements each set to 1.2em and the innermost is 1.728 times the root, not 1.2.

That compounding is a feature in one place and a trap everywhere else. It is exactly what you want for padding that should grow with the text it surrounds, since a button's padding in em scales automatically when the button's font size changes. It is exactly what you do not want for a type scale, where a heading three levels deep should not be silently three times larger than intended.

Using rem for font sizes has a second, less obvious benefit: it respects the visitor's own browser setting. Someone who has set their default font size to 20px because they find 16px hard to read gets larger text throughout, automatically. A layout built in px ignores that preference entirely, which is why overriding the root font size in CSS is a mistake — it takes the setting away again.

The type scale generator applies a fixed ratio between steps. The named ratios come from musical intervals, which is where the tradition comes from; a smaller ratio like 1.125 suits dense interfaces and a larger one like 1.5 suits editorial layouts with real hierarchy.

Everything runs in your browser.

Frequently asked questions

Should I use rem or em?

rem for font sizes, so nesting cannot compound and the visitor browser setting is respected. em for padding and margins that should scale with their own element text.

Why should I not change the root font size?

Because it overrides the visitor own browser setting. Someone who has set 20px because 16px is hard to read gets their preference taken away.

What ratio should a type scale use?

Around 1.125 to 1.25 for dense interfaces where sizes need to stay close, and 1.333 or higher for editorial layouts that want obvious hierarchy.