Skip to main content
Tools

CSS Unit Converter

Convert between px, rem, em, pt, vw, vh, cm and other CSS units, with your own root font size and viewport size.

You can type the unit too, e.g. 1.5rem or 12pt

Conversion basis
px
px
px
px

Results

24px = 24px

  • Pixels (px)input24px
  • Root em (rem)1.5rem
  • Parent em (em)1.5em
  • Percent (%, of parent font size)150%
  • Points (pt)18pt
  • Picas (pc)1.5pc
  • Inches (in)0.25in
  • Centimeters (cm)0.635cm
  • Millimeters (mm)6.35mm
  • Quarter-millimeters (Q)25.4Q
  • 1% of viewport width (vw)1.25vw
  • 1% of viewport height (vh)2.2222vh
  • 1% of the smaller side (vmin)2.2222vmin
  • 1% of the larger side (vmax)1.25vmax

CSS

font-size: 1.5rem; /* 24px */

Common sizes

With a 16px root and 16px parent font size

pxremempt%
10px0.625rem0.625em7.5pt62.5%
12px0.75rem0.75em9pt75%
14px0.875rem0.875em10.5pt87.5%
16px1rem1em12pt100%
18px1.125rem1.125em13.5pt112.5%
20px1.25rem1.25em15pt125%
24px1.5rem1.5em18pt150%
28px1.75rem1.75em21pt175%
32px2rem2em24pt200%
36px2.25rem2.25em27pt225%
40px2.5rem2.5em30pt250%
48px3rem3em36pt300%
56px3.5rem3.5em42pt350%
64px4rem4em48pt400%
72px4.5rem4.5em54pt450%
96px6rem6em72pt600%

How to use

  1. Enter a value and pick its unit, or type a value with a unit such as 1.5rem or 12pt.
  2. Set the root font size (usually 16px), the parent font size and the viewport size to match your site; the viewport defaults to this browser window.
  3. The value appears in every unit instantly; click “Copy” on any of them.
  4. In the CSS box, enter a property name and choose an output unit to copy a whole declaration.
  5. The table below lists common pixel sizes in rem, em, pt and percent.

FAQ

What is the difference between rem and em?

rem is always relative to the root (html) font size, which browsers set to 16px by default, so 1.5rem is 24px. em is relative to the parent’s font size (or the element’s own font size for padding and margin) and compounds when nested. Use rem for layout sizes and em for spacing that should scale with the text.

Why use rem instead of px for font sizes?

People can raise the default font size in their browser settings. With rem the whole site scales with it; hard-coded px does not, which hurts readers with low vision.

Is 1cm in CSS really one centimeter?

Not necessarily. CSS defines 1in as 96px and derives cm, mm and pt from that, so the physical size on screen depends on the device’s pixel density and zoom. Physical units are mostly useful in print styles.

What is % relative to?

Here % is relative to the parent font size, as it is for font-size (150% = 1.5em). For width, padding and similar properties % refers to the container’s width instead, which cannot be converted to px on its own.

How are vw, vh, vmin and vmax calculated?

1vw is 1% of the viewport width and 1vh 1% of its height; vmin and vmax use the smaller and larger of the two. Mobile address bars affect vh, so consider the newer dvh and svh units where that matters. All calculations run in your browser.

Keyboard shortcuts

/
Search tools (on a tool page, goes to the homepage search)
?
Show this help
Esc
Close a dialog
Ctrl / ⌘Enter
Run the tool's main action (where supported)

While you type in a text field, / and ? are typed as usual.