This calculator converts between the three CSS length units web designers and developers use most: pixels (px), em, and rem, so you can move between an absolute unit and two relative ones without manual maths. You enter a root font size (the html element's size, which browsers default to 16px), a parent element font size (used for em conversions), and a value in any one of the three units; edit any field and the other two update instantly. The results bar shows the converted values in px, em, and rem, while a reference table lists common sizes such as 12px, 16px, 24px and 32px alongside their rem and em equivalents and typical uses like body text or headings. A conversion formulas panel spells out exactly how each unit is derived from the others, and a worked example walks through a live calculation using your current inputs. A preset dropdown lets you jump between common root sizes, including the 10px "62.5 percent trick" some developers use to simplify rem arithmetic. Use this tool when building a responsive layout, converting a legacy px-based stylesheet to rem, or checking how nested em values will compound relative to a parent. Because em and rem are relative units, their pixel equivalent always depends on the root and parent sizes you set, so check those match your actual project before applying the results.
Edit any field to convert from that unit. Other fields update automatically.
| px | rem (root: 16px) | em (parent: 16px) | Common use |
|---|
CSS offers two broad categories of length units: absolute and relative. Pixels (px) are absolute. They represent a fixed size on the screen and do not change with surrounding context. Em and rem are both relative units, but they reference different things.
The em unit is relative to the font size of the current element's parent. If a <div> has font-size: 20px, then 1.5em inside that div equals 30px. The key challenge with em is compounding: if you nest elements that each use em, the effective pixel size can grow unexpectedly because each level multiplies from its parent.
Formula: em = px / parent font size and px = em * parent font size
The rem unit (root em) always refers to the font size of the root <html> element. Because it ignores nesting, it is easier to reason about across a complex component tree. The browser default root font size is 16px, so 1rem = 16px unless you override it.
Formula: rem = px / root font size and px = rem * root font size
A popular pattern sets html { font-size: 62.5%; } so that the root becomes 10px (62.5% of the browser default 16px). This makes mental arithmetic simple: 1.6rem = 16px, 2.4rem = 24px, and so on. The trade-off is that you must override the base for accessibility reasons, since some browser accessibility settings that increase the default font size will be overridden by a hard percentage set on the root. Use the 10px preset in this converter to see conversions at that scale.
| Unit | Best for | Avoid when |
|---|---|---|
px | Borders, shadows, fine details that should not scale | Font sizes and spacing that should respect user preferences |
em | Component-relative spacing (padding proportional to the component's text) | Global layout spacing where compounding becomes confusing |
rem | Font sizes, global spacing, layout rhythm | When you need spacing tied to the local font size of a component |
Users can set their browser's default font size to accommodate vision needs. If your stylesheet uses rem or em for font sizes, those sizes will scale with the user's preference. If you use px exclusively, your text will not scale, which can make the page inaccessible. The Web Content Accessibility Guidelines (WCAG) 2.1 require text to be resizable up to 200% without loss of content, and using relative units is the most reliable way to meet that standard.
Sources and method: CSS Values and Units Module Level 4 (W3C, www.w3.org/TR/css-values-4). MDN Web Docs on CSS length units (developer.mozilla.org/en-US/docs/Web/CSS/length). Formulas applied: rem = px / root size; em = px / parent size; px = rem * root size; px = em * parent size; em to rem = em * parent size / root size.
This converter calculates CSS unit relationships based on the root and parent font sizes you specify. Actual rendered sizes depend on your browser, operating system, and any font-size overrides in your CSS cascade.
If you've found a bug, or would like to contact us, or learn more about James Graham and Calculate.co.nz.
Calculate.co.nz is partnered with Interest.co.nz for New Zealand's highest quality calculators and financial analysis.
Calculate.co.nz is the sister site of CalculatorHub.com, the world's largest calculator website by tool count.
All calculators and tools are provided for educational and indicative purposes only and do not constitute financial advice.
Calculate.co.nz is proudly part of the Realtor.co.nz group, New Zealand's leading property transaction literacy platform, helping Kiwis understand the home buying and selling process from start to finish. Whether you're a first home buyer navigating your first property purchase, an investor evaluating your next acquisition, or a homeowner planning to sell, Realtor.co.nz provides clear, independent, and trustworthy guidance on every step of the New Zealand property transaction journey.
Calculate.co.nz is also partnered with Health Based Building and Premium Homes to promote informed choices that lead to better long-term outcomes for Kiwi households.
Calculate.co.nz is hosted in Auckland via SiteHost new Zealand.
All content on this website, including calculators, tools, source code, and design, is protected under the Copyright Act 1994 (New Zealand). No part of this site may be reproduced, copied, distributed, stored, or used in any form without prior written permission from the owner.
About & trust: Why Calculate is NZ's most comprehensive · By the Numbers · How we compare · Editorial standards · How we keep data current · NZ finance glossary · Research & data · Financial literacy NZ · About · Privacy policy · Terms of use
Reviewed and maintained. Last reviewed 2026-07-02 and checked on a twice-monthly cycle against IRD, RBNZ and Stats NZ. How we keep data current.
© 2026 Calculate.co.nz. All rights reserved. Building free NZ calculators since 2011.