Skip to tool
ecech.
🎨 Design & Color

rem Is 14.4px at Every Nesting Level. em Is Not.

em multiplies with each nested level, so four levels of 0.9em is 10.5px, not 14.4. Convert between all three and see the compounding.

px
px

Pixels

rem

relative to the root

em

relative to the parent

Percent

same as em, different syntax

What happens when you nest

A scale to copy

Advertisement

How the calculation works

Four nested elements, each set to 0.9 of its unit 0.9em 14.4012.96 11.6610.50 shrinking every level 0.9rem 14.4014.40 14.4014.40 identical every level em asks its parent. rem asks the root, and the root does not move. This is why a component in em shrinks when someone nests it inside another one.

How to Use This Tool

Type a pixel value or a rem value and the others follow. The nesting panel shows the behaviour that makes the choice matter.

What each unit is relative to

  • px — an absolute CSS pixel. Fixed, and ignores the user's browser font setting.
  • rem — the root element's font size. Usually 16px unless the user has changed it.
  • em — the parent element's font size, so it compounds with nesting.
  • % — for font-size, identical to em with different syntax. 90% and 0.9em are the same thing.

The compounding

Because em looks at its parent, nested em values multiply. Four levels each at 0.9em, starting from 16px, gives 14.40, 12.96, 11.66 and 10.50 pixels. The same four levels at 0.9rem give 14.40 every time.

This is the practical reason rem became the default for type. A card component styled in em is a different size depending on what it happens to be inside, and nobody notices until it appears in two places at once.

A user who set their browser font to 20px font-size: 16px still 16px — the setting is ignored font-size: 1rem 20px — the setting is respected People change that setting because they need to. Sizing type in px overrides them, silently, on every page.
The accessibility argument for rem, which matters more than the maths one.

The reason that is not about maths

Users can change their browser's default font size, and some do because they need to. Anything sized in rem scales with that setting. Anything sized in px does not.

So sizing body text in pixels silently overrides a preference someone set deliberately, and they cannot fix it from their end. This is the strongest argument for rem and it has nothing to do with nesting.

The 62.5% trick, and why to skip it

An old technique sets html { font-size: 62.5% } so that 1rem equals 10px and the mental arithmetic gets easier. It works, and it has a cost: it overrides the user's chosen font size with a proportion of it, and any component or third-party stylesheet assuming a 16px root now renders small.

Modern editors show the pixel equivalent of a rem value on hover, which removes the only problem the trick solved. Leave the root alone.

Where em is still right

em is the better unit whenever a value should scale with this element's own text rather than with the page:

  • Padding inside a button, so a large button gets proportionally more padding.
  • Letter spacing and text indent, which are properties of the type.
  • Border radius on a text-sized component, for the same reason.

A useful rule: rem for anything that should match the page, em for anything that should match the element. Media queries are a separate case — they ignore the root font size and use the browser default regardless, so em and rem behave identically there.

Advertisement

Frequently Asked Questions

What is the difference between em and rem?
rem is relative to the root element's font size and em is relative to the parent's. Because em looks at its parent, nested em values multiply — four levels of 0.9em from a 16px root gives 10.5px, while 0.9rem gives 14.4px at every level.
How many pixels is 1rem?
16px by default, because that is the usual browser default font size. But a user can change that setting, and anything in rem scales with it — which is the point. If you have changed the root font size in CSS, 1rem is whatever you set.
Should I use px or rem for font sizes?
rem, in almost every case. A user who has increased their browser's default font size gets that applied to rem values and ignored by px values, so sizing text in pixels silently overrides a preference they set deliberately and cannot work around.
Is the 62.5% root font size trick a good idea?
It makes the arithmetic easier and costs you the user's font size preference, since it scales their setting to 62.5% of what they chose. It also breaks components and third-party stylesheets that assume a 16px root. Modern editors show pixel equivalents on hover, which solves the original problem without the cost.
When should I use em instead of rem?
When a value should scale with the element's own text rather than with the page — padding inside a button, letter spacing, text indent, or a border radius on a text-sized component. A large button then gets proportionally more padding automatically.
Do media queries use rem or px?
Media queries ignore the root font size entirely and use the browser's default, so em and rem behave identically inside them. This surprises people who change the root size and expect their breakpoints to move with it.

Related tools in Design & Color

Browse all Design & Color tools
The person who builds ecech., at the desk where the tools are written.

Made by one person

ecech. is not a content farm. Every tool here is written and checked by hand, one at a time, by someone who wanted the tool to exist and could not find a version that showed its working.

No accounts and no sign-in, and nothing you type reaches a server — every calculation on this page runs inside your browser. The ads are served by Google and do set their own cookies, which is set out in full on the privacy page. More about the site.