</>
DevToolHub

CSS Unit Converter

Convert between px, rem, em, pt, %, vw, and vh instantly. Set your base font size, enter a value in any unit, and see all conversions at once. Bidirectional — edit any output to update everything.

Settings
Input Value
Quick presets (px)
Converted Values
px
rem
em
pt
%
vw
vh
PX to REM Conversion Table (base: 16px)
pxremempt
1px0.0625rem0.0625em0.75pt
2px0.125rem0.125em1.5pt
4px0.25rem0.25em3pt
6px0.375rem0.375em4.5pt
8px0.5rem0.5em6pt
10px0.625rem0.625em7.5pt
12px0.75rem0.75em9pt
14px0.875rem0.875em10.5pt
16px1rem1em12pt
18px1.125rem1.125em13.5pt
20px1.25rem1.25em15pt
22px1.375rem1.375em16.5pt
24px1.5rem1.5em18pt
28px1.75rem1.75em21pt
32px2rem2em24pt
36px2.25rem2.25em27pt
40px2.5rem2.5em30pt
44px2.75rem2.75em33pt
48px3rem3em36pt
56px3.5rem3.5em42pt
64px4rem4em48pt
72px4.5rem4.5em54pt
80px5rem5em60pt
96px6rem6em72pt
100px6.25rem6.25em75pt

How It Works

Every CSS unit ultimately maps to a pixel value on screen. This tool converts between units using these formulas:

ConversionFormulaExample (base 16px)
px to rempx / baseFontSize24px / 16 = 1.5rem
rem to pxrem * baseFontSize1.5rem * 16 = 24px
em to pxem * baseFontSize1.5em * 16 = 24px
pt to pxpt * 1.33312pt * 1.333 = 16px
px to ptpx / 1.33316px / 1.333 = 12pt
% to px(% / 100) * baseFontSize150% / 100 * 16 = 24px
vw/vh to px(vw / 100) * viewportWidth50vw / 100 * 1920 = 960px

Note on em: In real CSS, em is relative to the parent element's font size, not the root. This tool uses the base font size as a simplified approximation. For deeply nested elements, the actual computed value may differ.

PX vs REM vs EM: When to Use Each

UnitRelative ToBest ForExample
pxNothing (absolute)Borders, shadows, precise layoutsborder: 1px solid
remRoot font size (<html>)Typography, spacing, responsive layoutsfont-size: 1.125rem
emParent font sizeComponent-scoped sizing, padding relative to textpadding: 0.5em 1em
pt1/72 of an inchPrint stylesheets, PDF generationfont-size: 12pt
%Parent elementFluid widths, responsive font scalingwidth: 50%
vwViewport widthFull-width sections, fluid typographyfont-size: 5vw
vhViewport heightFull-height sections, hero bannersheight: 100vh

Rule of thumb: Use rem for most font-size and spacing values. Use px for borders and box-shadows where you want exact pixel control. Use em when you want an element's dimensions to scale with its own font-size (like padding on a button).

FAQ

What's the default browser font size?

All major browsers set the default root font size to 16px. This means 1rem = 16px unless the user or a stylesheet overrides it. Some developers set html { font-size: 62.5% } to make 1rem = 10pxfor easier math, though this practice is falling out of favor because it forces you to override every element's font size.

Should I use rem or em?

Use rem for global consistency — every rem value maps to the same root size, so 1.5rem always means the same thing regardless of nesting. Use emwhen you want sizing to scale with the element's own font-size, like padding on a button that should grow proportionally when the button text gets larger. Avoid deeply nested em values — they compound, so 1.2em inside 1.2em gives you 1.44em of the root, which gets confusing fast.

How does base font size affect rem?

The rem unit is calculated relative to the <html>element's font-size. If the root is16px (the default), then 1rem = 16px. Change the root to 20px, and 1rem = 20px. This is what makes rem powerful for responsive design — adjust one value and everything scales. Use the base font size control above to see how changing it affects all conversions.

Can I mix px and rem?

Absolutely, and most production codebases do. A common pattern is: rem for font-size, margin, and padding (so they scale with user preferences); px for borders, box-shadows, and outline-offset (where fractional pixels cause blurry rendering); em for component-local padding (so buttons scale with their text). Consistency within each category matters more than using a single unit everywhere.

Need CSS effects? Glassmorphism Generator creates frosted-glass CSS you can combine with any unit system. Or use the Color Converter to find the right colors for your designs.