How the px → em → rem conversion works
px are absolute (device pixels), while em and rem are relative. Responsive web design prefers relative units because they scale with user settings and container font-sizes.
Formulas
em = px ÷ contextFontSize
rem = px ÷ rootFontSize
If you know em and want px: px = em × contextFontSize
em vs rem
em is relative to the current element’s font-size and compounds (nested elements can multiply the effect). rem is relative to the root HTML font-size and stays consistent throughout the document.
FAQ
1. Which unit should I use for padding/margin?
Use em if you want spacing to scale with the element’s text; use rem for consistent spacing across components.
2. My design is in Figma in px — what do I enter?
Enter the exact px from the design, then input the real font-size used in that component. The converter will output em/rem you can paste into your CSS.
3. Why is my number not round?
Because not all px values divide evenly by your chosen font-size. You can round to 3–4 decimals; browsers handle that fine.
Formula (LaTeX) + variables + units
','\
em = px ÷ contextFontSize rem = px ÷ rootFontSize If you know em and want px: px = em × contextFontSize
- No variables provided in audit spec.
- NIST — Weights and measures — nist.gov · Accessed 2026-01-19
https://www.nist.gov/pml/weights-and-measures - NIST — SI units — nist.gov · Accessed 2026-01-19
https://www.nist.gov/pml/owm/metric-si/si-units
Last code update: 2026-01-19
- Initial audit spec draft generated from HTML extraction (review required).
- Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
- Confirm sources are authoritative and relevant to the calculator methodology.