em compounds through the DOM tree — so the rendered px depends on context. Set your base size and see the result instantly.

The CSS em unit is relative to the font size of the parent element. If the parent font size is 16px (browser default), then 1em = 16px, 1.5em = 24px, 2em = 32px.
Em units are commonly used in responsive web design for typography, spacing, and layout. Converting to pixels helps understand the actual rendered size.
Unlike rem (which is relative to root), em compounds: if a parent is 1.5em and a child is 1.5em, the child renders at 1.5 × 1.5 = 2.25× the base size.
All calculations run locally in your browser — nothing is sent to any server.
px = em × parent font size. By default, the browser base font size is 16px.
Em compounds through the DOM tree. If body is 16px and a div is 1.5em (24px), a paragraph inside at 1.5em will be 1.5 × 24 = 36px.
For predictable sizing, consider using rem units instead — they always reference the root element font size.
| Feature | em | px |
|---|---|---|
| Reference | Parent font size | Fixed pixel |
| Compounds | Yes (nests) | No |
| Responsive | Yes | No |
| Accessibility | Respects user settings | Fixed size |
| Predictability | Context-dependent | Always consistent |
By default, 1em = 16px (browser default font size). But em is relative to the parent element font size, so it changes based on context. If a parent div has font-size: 20px, then 1em inside it equals 20px, not 16px.
em is relative to the parent element font size and compounds through DOM nesting. rem is always relative to the root (html) element font size and never compounds. For predictable spacing systems, rem is usually preferred.
Use em when you want a component to scale proportionally with its own font size — for example, button padding, icon sizes within text, or line-height. Use rem for global spacing. Use px for borders and box-shadows that should stay fixed.
Set html { font-size: 62.5% } to make 1rem/1em = 10px at the root level. Then 1.6rem = 16px, 2rem = 20px — easier mental math. Note: this affects em values too, so nested em calculations change accordingly.
Bootstrap 5 media queries use em units internally. sm = 36em (576px), md = 48em (768px), lg = 62em (992px), xl = 75em (1200px), xxl = 96em (1400px) — all at 16px root.
When users zoom in using the browser, em-based font sizes scale correctly because the root font size scales proportionally. px-based layouts can break or overflow, which is why em and rem are recommended for accessible typography.
Yes. In Sass you can store base font sizes as variables and calculate em values: $base: 16px; font-size: #{14px / $base}em. Some teams also use the em() function in their own Sass utilities to automate the conversion.
Yes. All calculations run in your browser. No data is sent to any server.

Have an idea, found a bug, or want to suggest a feature? Drop us a message – we respond within 24 hours.