Convert between px, em, rem, %, vw, vh
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.
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.
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