Five units can set a font-size in CSS, and each one answers a different question. Using the wrong one is how you get a modal whose text scales but whose padding does not.
px - fixed, predictable, wrong for text
font-size: 16px ignores the user's browser font-size preference. Some users set 20px defaults because they need larger text; px sizing silently overrides that. Use px for borders, shadows, and decorative offsets - never for reading text.
rem - the reading unit
1rem = the root (html) font-size, which respects the user's preference. Body text, headings, and spacing for text containers belong in rem. One line: html { font-size: 100%; } and everything in rem now scales with user settings.
em - the component unit
em is relative to the element's own font-size - which makes it perfect for things that should scale WITH the text: padding around a button whose label is in rem, icon sizing inside a heading. The catch: em compounds in nested elements, which is where the bugs live.
ch - the measure unit
1ch = the width of the "0" glyph. The readable line length is 45-75 characters, so max-width: 70ch gives you correct line length at any font size. This is the single most underused unit in typography CSS.
The winning combination
html { font-size: 100%; }
body { font-size: 1rem; line-height: 1.5; max-width: 70ch; }
button { padding: 0.5em 1em; } /* scales with its label */
When units meet fonts
Typography audits sometimes reveal that a "mystery font" renders differently across breakpoints because em-based sizing compounded unexpectedly. When you inherit such a page, identify what is actually rendering first - a screenshot through an on-device identifier like Typeye names the real typeface locally - then normalize the units. Fix the units, keep the font.
Start with rem for text, em for components, ch for measures. px stays in the decorative layer.
Top comments (0)