Em
Embed This Widget
Add the script tag and a data attribute to embed this widget.
Embed via iframe for maximum compatibility.
<iframe src="https://fontfyi.com/iframe/glossary/em/" width="420" height="400" frameborder="0" style="border:0;border-radius:10px;max-width:100%" loading="lazy"></iframe>
Paste this URL in WordPress, Medium, or any oEmbed-compatible platform.
https://fontfyi.com/glossary/em/
Add a dynamic SVG badge to your README or docs.
[](https://fontfyi.com/glossary/em/)
Use the native HTML custom element.
A typographic unit equal to the current font size. In CSS, 1em = the parent element's font size. The basis for relative sizing.
The em is a typographic unit of measurement equal to the current font size. If an element's font size is 16px, then 1em equals 16px in that context. If the font size changes to 24px, 1em becomes 24px. This proportional relationship is what makes em units powerful — they scale automatically with the text they're associated with.
The name comes from the width of the uppercase letter 'M' in traditional metal type, which was historically the widest character and used as a reference square. In modern typography, the em is defined purely as a unit equal to the current font size, regardless of any actual letter dimensions.
/* em values scale with the inherited font-size */
.parent {
font-size: 16px;
}
.child {
font-size: 1.25em; /* 1.25 × 16px = 20px */
padding: 1em; /* 1 × 20px = 20px — scales with THIS element's font-size */
margin-bottom: 1.5em; /* 1.5 × 20px = 30px */
}
/* The key difference from rem (root em) */
html {
font-size: 16px;
}
.card {
font-size: 0.875rem; /* 14px — relative to root */
padding: 1em; /* 14px — relative to this element's font-size */
border-radius: 0.5rem; /* 8px — always relative to root */
}
/* Em units for letter-spacing are best practice */
h1 {
font-size: 3rem;
letter-spacing: -0.02em; /* -0.02 × 48px = -0.96px — scales correctly */
}
/* vs. pixel-based letter-spacing that breaks at different sizes */
h1.broken {
letter-spacing: -1px; /* Fixed — won't scale if font-size changes */
}
Understanding the distinction between em and rem is critical. em is relative to the current element's font-size (or the nearest parent's font-size, when used for font-size itself). rem is always relative to the root element's font-size (html). This means em units can compound — a child inside a child can have a surprisingly small or large value — while rem values are always predictable.
For typography specifically, em units shine for letter-spacing, line-height, and spacing properties (padding, margin) that should scale proportionally with text. When you want consistent ratios that hold across type sizes, em is the right tool. Google Fonts documentation and most modern design systems document spacing in em values for exactly this reason.
相关术语
相关工具
展示此概念的字体
了解更多
使用 px 设置字号会破坏视障用户的浏览器缩放功能。这里介绍为何 rem 至关重要,以及如何正确实现。
CSS 排版CSS 单位的永恒问题,清晰解答。何时使用 px、rem 和 em 来设置字号、间距和响应式设计。
CSS 排版使用 CSS 的 clamp() 构建能在不同视口尺寸间平滑缩放的响应式排版。无需断点,无需媒体查询,一行 CSS 即可实现。
排版基础字距调整的三大支柱——字偶间距(字母对间距)、字符间距(整体字间距)和行距(行间距)。微小的调整,巨大的影响。