CSS Unit Converter

Convert between px, rem, em, vw, and pt โ€” with configurable base font size.

[ Advertisement ]
Base font size
px
Viewport width
px
Value in px
px
Enter a px value to see conversions โ€” click any result to copy
[ Advertisement ]

CSS units: when to use which

px (pixels) are absolute and predictable, useful for borders, shadows, and fixed-size elements. However, they don't scale with the user's browser font size preference, which can be an accessibility issue for text.

rem (root em) scales relative to the root html element's font size (default 16px). Using rem for font sizes and spacing ensures your layout respects user accessibility preferences. The modern recommendation: set your base size in px, use rem for everything else.

vw and vh (viewport width/height) are percentages of the browser window. They're ideal for full-screen sections and fluid typography. The modern clamp() function โ€” e.g. clamp(1rem, 2.5vw, 2rem) โ€” combines units for fluid, bounded sizing.

Frequently asked questions
What is the difference between px, em, and rem?
px is absolute. em is relative to the parent element font size. rem is relative to the root (html) font size โ€” typically 16px.
How do I convert px to rem?
Divide the px value by the base font size (usually 16). For example, 24px รท 16 = 1.5rem.