CSS Unit Converter

Convert between px, em, rem, %, vw, vh

Convert Units
Result
Click "Convert" to see result

What is CSS Unit Conversion?

CSS offers many units for sizing: absolute units like pixels (px) and relative units like em, rem, percentages (%), and viewport units (vw, vh). Understanding and converting between these units is crucial for responsive web design, accessibility, and cross‑device consistency.

This tool converts values between the most common CSS units. For conversions involving em and rem, the base font size (typically 16px) is used. For percentages, the conversion assumes the reference is the parent element's size (for width/height) – you can adjust the base values accordingly. Viewport units are calculated based on the viewport dimensions you provide.

All calculations are performed client‑side, ensuring privacy and instant results.

How to Use

Step 1: Enter the numeric value you want to convert.
Step 2: Select the source unit (the unit of your input value).
Step 3: Select the target unit you want to convert to.
Step 4: Adjust the base font size (for em/rem), viewport width (for vw), and viewport height (for vh) as needed.
Step 5: Click "Convert" to see the result.
Step 6: Copy the result using the "Copy Result" button.

Note: For percentage conversion, the tool assumes a reference size of 100% = parent element's computed width/height. You can adjust the base context by modifying the viewport width/height for vw/vh, but for percentage it's less straightforward; use with understanding.

Examples

px → em: 16px → 1em (with base 16px)
em → px: 2em → 32px (with base 16px)
px → rem: 24px → 1.5rem (with root base 16px)
px → %: 100px on a 1000px container → 10%
px → vw: 100px on a 1920px viewport → 5.208vw

Who Uses CSS Unit Converters?

  • Web Designers – creating responsive layouts.
  • Front-End Developers – converting design specs to flexible units.
  • UI/UX Designers – ensuring consistency across breakpoints.
  • Students – learning CSS units.
  • Email Designers – converting px to em for email compatibility.

Pro Tips

  • Always consider the context: em units are relative to the parent font size, rem to the root element.
  • For responsive design, prefer rem for typography and vw/vh for full‑viewport elements.
  • When converting px to %, make sure you know the parent element's dimensions.
  • Use the copy button to quickly paste values into your CSS.
  • Double-check your base font size if your site uses a different default (often 16px, but can be changed).

Frequently Asked Questions

What is the difference between em and rem?
em is relative to the font size of the parent element; rem is relative to the root element (html) font size. This makes rem more predictable for global typography.
Why do I need to set viewport width/height for vw/vh conversion?
vw and vh are percentages of the viewport size. Without knowing the viewport dimensions, we cannot calculate absolute pixel values. You can input typical screen sizes (e.g., 1920x1080).
What about other CSS units like ch, ex, cm, etc.?
This tool covers the most common responsive units. For absolute units like cm, mm, etc., they are rarely used in web design and can be approximated.
Does it account for different root font sizes?
Yes, you can set the base font size. The default is 16px, which is standard for most browsers.
Is my data sent to a server?
No, all calculations are done locally in your browser.
Can I convert percentages to pixels?
Yes, but you need to know the reference size (e.g., parent element width). Enter that in the viewport width field if the percentage is relative to width, or use height accordingly.
Why are the results rounded?
CSS supports fractional values; results are displayed with up to 4 decimal places for accuracy.