Skip to main content

What Is EMS In CSS?

by
Last updated on 6 min read

In CSS, an em (short for “em”) is a scalable unit of measurement equal to the computed font-size of the element it’s applied to.

How do ems work in CSS?

An em in CSS acts as a scalable unit that inherits its value from the font-size of its parent element.

Take a <div> with a font-size of 16px. Inside that <div>, 1em equals 16px—and so does any child element’s 1em. This makes spacing, margins, and padding grow or shrink automatically when font size changes, keeping layouts consistent across devices. According to MDN Web Docs, em units shine in responsive typography and components that need to adapt to user preferences or system settings.

What is em in CSS style?

An em is a relative unit in CSS that represents the current font size of an element.

Back in metal type days, “em” meant the width of the uppercase letter “M.” Today, 1em always equals the font-size of the element itself. No font size set? It falls back to the browser’s default 16px. As W3C explains, em units help create layouts that respond to user-defined text sizes, boosting accessibility across devices.

Why do we use em in CSS?

We use em units in CSS to create scalable designs that adapt to user preferences and improve accessibility.

Unlike fixed pixels, ems let text and spacing grow or shrink based on browser settings or screen size. That matters for users who need larger text to read comfortably. As WebAIM points out, em units help keep layouts intact when font sizes change, preventing text overflow or broken designs in older browsers or assistive tech.

What is em and REM CSS?

In CSS, em and rem are both relative units, but em scales based on the parent element’s font size, while rem scales from the root (html) font size.

Think of rem as the steady sibling: 1rem always matches the <html> element’s font size (usually 16px), so it stays consistent everywhere. Em, though, takes its cue from the immediate parent. Nest three elements with 1.2em each, and you’ll end up with 1.728em. CSS-Tricks suggests using rem for global sizing (like spacing and typography) and em for component-specific scaling.

How do you emphasize CSS?

You emphasize text in CSS by applying the <strong> or <em> tags in HTML and styling them with CSS.

By default, <strong> shows up bold, and <em> in italics—but you can override those styles however you like. Maybe you’ll make <em> text red or underlined instead. As the MDN documentation shows, semantic HTML tags like these improve accessibility and SEO while giving you plenty of styling freedom.

What is EMS size?

An em size is a typographic unit that equals the current font size of its element in points or pixels.

Say you’re working with 16px text—1em equals 16px. This unit stays consistent across typefaces at the same point size and is a go-to for scalable CSS layouts. The em unit even gives us typographic tools like the em dash (—) and em space, each one em wide. For a bit of history and modern examples, check out the Wikipedia article on em units.

What does P mean in HTML?

The <p> tag in HTML stands for the paragraph element, used to define blocks of text.

The <p> element is a block-level tag that adds vertical spacing (margin) before and after your text, neatly separating paragraphs. It’s a core HTML building block for readable content. According to MDN Web Docs, you can put inline elements like links or emphasis tags inside a <p>, but avoid nesting block-level elements like headings or other paragraphs.

How many em is a space?

An em space is defined as exactly 1em wide, which scales with the font size of the element.

NameWidth (CSS)Example Value
thick space5/18 em0.2778em
three per em space1/3 em0.3333em
en space1/2 em0.5em
em space1 em1em

These spacing values come straight from the CSS Text Module Level 3 specification. The em space is especially handy for consistent indentation or alignment in responsive designs.

How is em calculated?

An em is calculated as the computed font-size of the element’s parent; if no parent font size is set, it defaults to the browser’s base font size (typically 16px).

Imagine a <div> whose parent has a 20px font size. Inside that <div>, 1em equals 20px—and its children inherit that value unless you override it. As MDN warns, nested ems can surprise you if you’re not careful. Browser dev tools (F12) let you inspect computed font sizes in real time, so you can spot scaling issues early.

Should I use pixels or EMS?

Modern browsers handle zooming well with pixel units, so use pixels for precise control and ems for scalable, responsive layouts.

Pixels (px) are fixed, so they don’t respond to user preferences—though browser zoom (Ctrl/Cmd +) can scale the whole page, including px-based elements. Still, WebAIM recommends em units for readability across devices. Pixels aren’t obsolete, though: they’re still great for layout elements like borders or image dimensions where you don’t want scaling.

How many pixels is an em?

The pixel equivalent of 1em depends on the element’s font size; for example, 1.5625em equals approximately 25px when the base font size is 16px.

pxempercent
25px1.5625em156.25%

Need to convert an old px-based design to em units? Tools like PXtoEM.com or browser dev tools can do the math for you, keeping everything accurate across different base font sizes.

What are CSS pixels?

CSS pixels (px) are absolute length units defined as exactly 1/96th of an inch, standardizing display across devices.

Don’t let the name fool you: CSS pixels aren’t the same as physical screen pixels, especially on high-DPI (Retina) displays. One CSS pixel can map to multiple physical pixels there. This abstraction keeps sizing consistent everywhere. According to the W3C CSS Values and Units Module Level 3, px units are perfect for precise control over elements like borders, shadows, or fixed-width layouts where scaling isn’t welcome.

Should I use em or REM?

Use rem units for most global sizing (like spacing, typography, or layout), and em units for component-specific scaling where you need to inherit from a parent’s font size.

Set your base font size with rem (e.g., html { font-size: 16px; }), then use rem for padding, margins, and font sizes throughout your site. That keeps everything consistent. Save em for cases like button padding or nested list indentation, where you want the size to scale relative to the component’s own font size. CSS-Tricks swears by this approach to dodge compounding em values in deep nesting.

Is em same as REM?

No, em and rem are not the same; em scales relative to the parent element’s font size, while rem scales relative to the root (<html>) font size.

This difference matters. Say you’ve got a <div> with a 20px font size. Inside it, 1.5em equals 30px. But 1.5rem always equals 24px if the root font size is 16px. MDN calls rem less prone to unexpected scaling in complex layouts, making it the safer pick for most situations.

What is difference between REM and em in CSS?

The key difference is scope: em scales based on the font size of its nearest parent, while rem scales from the root font size of the document.

Em can stack up quickly. Nest 1.2em inside another 1.2em, and you’re looking at 1.44em. Rem, on the other hand, stays predictable everywhere. SitePoint generally recommends rem for typography and layout, while em works better for specific components like icons or buttons where local scaling is useful.

Edited and fact-checked by the TechFactsHub editorial team.
Alex Chen

Alex Chen is a senior tech writer and former IT support specialist with over a decade of experience troubleshooting everything from blue screens to printer jams. He lives in Portland, OR, where he spends his free time building custom PCs and wondering why printer drivers still don't work in 2026.