📐
CSS Unit Converter — px ↔ rem ↔ em
Convert between px / rem / em / pt / % / vw / vh in CSS. Adjustable base font-size and viewport. Perfect for design systems and responsive layouts.
Default 16px (browser default). Change if your page uses a custom html/body font-size.
+ Advanced
For em — parent element font-size (default = base)
Common values:
Equivalent values
CSS Unit Converter — switch between px / rem / em / pt / % / vw / vh. Useful for design systems and responsive layouts.
rem is relative to the <html> root font-size. em is relative to the parent element. Default browser is 16px.
When to use which CSS unit?
- px — fixed pixels. Use for borders, shadows, small icon sizes. Doesn't scale with user zoom.
- rem — relative to
<html>font-size (default 16px). Best for font-size and spacing — scales when users change their default font. - em — relative to the parent's font-size. Good for padding/margin inside buttons or badges — scales with context.
- % — relative to the parent's corresponding value (width/height/font-size). Useful for fluid layouts.
- vw / vh — 1% of viewport width/height. Use for full-screen heroes or responsive font sizes.
- pt — point (1/72 inch). Rarely used on the web — mostly for print and PDF.
Rules of thumb
- 16px = 1rem (browser default). Foundation of every calculation.
- Tailwind uses rem:
p-4=1rem=16pxby default. - Font-size: use rem. Borders & shadows: use px. Hero sections: use vh.
- Avoid em in nested components — scaling can compound unpredictably.
Tips
- Change Base font-size if your page uses
html { font-size: 14px }— the conversion updates instantly. - Click 12px / 16px / 24px preset buttons to quickly check common sizes.
- Click "Copy" on any card to paste straight into CSS.
Related
- Color Picker — pick colors with Tailwind names
- All tools
Related tools
See all tools →NEW
🔐
JWT Decoder
Decode JWT tokens — header, payload, claims with readable timestamps.
NEW🎨
JSON Formatter
Format / minify / validate JSON. Sort keys A-Z, custom indent, Ctrl+Enter shortcut.
NEW🔍
Regex Tester
Test regex live with match highlighting. 7 ready presets including Vietnamese.
NEW🔑
UUID / Hash / Base64 / URL
Bundle: UUID v4, SHA-256/512 hash, Base64 (URL-safe), URL encode.