CSS & Design7 min readAugust 15, 2026

Modern CSS Units in 2026: Master rem, em, ch, and Dynamic Viewports (dvh/dvw)

Stop guessing CSS units. Learn the exact differences between rem, em, px, ch, vw, vh, and modern dynamic viewport units (dvh, svh, lvh). Build accessible, scalable responsive typography and layouts.

ToolBean UI/UX Team

ToolBean UI/UX Team

Frontend Design Systems Engineers

Try the Companion Tool

CSS Units Converter

Convert between pixels (px), rem, em, vw, vh, points (pt), and percentages with dynamic base font adjustment.

Launch Tool

1. The Evolution of CSS Sizing Units

Modern CSS has evolved far beyond static pixels (px). Today's responsive layouts demand relative units that adapt fluidly across devices, screen orientations, and user accessibility preferences.

2. Deep Dive: 'rem' vs 'em'

Unit Relative To Best Used For
rem (Root EM) Font size of the root element (<html>, usually 16px) Global typography, layouts, grid gutters, section margins
em Font size of the immediate parent element Component padding, icon sizing, scalable buttons

3. The New Viewport Units: dvh, svh, and lvh

For years, mobile developers struggled with the infamous 100vh bug, where full-screen hero sections overflowed below mobile URL bars. CSS Viewport Units Level 4 introduced three precise viewport definitions:

  • svh (Small Viewport Height): Represents the viewport when mobile UI elements (address bar, toolbar) are fully expanded. Safe from overflow.
  • lvh (Large Viewport Height): Represents the viewport when all browser UI elements are fully collapsed.
  • dvh (Dynamic Viewport Height): Dynamically adjusts in real-time as the user scrolls and browser bars expand or contract.
/* Perfect mobile-friendly full-screen hero */
.hero-section {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

4. Character Units: The Secret to Readable Typography (ch)

The ch unit equals the width of the zero character (0) in the current font. Web typography research recommends maintaining line lengths between 45 to 75 characters for optimal reading comprehension.

/* Optimal readable article container */
.article-content {
  max-width: 65ch;
  margin-inline: auto;
}

Frequently Asked Questions

Using 'rem' respects user accessibility settings. If a visually impaired user increases their default browser font size from 16px to 24px, 'rem'-based typography will scale accordingly, whereas fixed 'px' values ignore user preferences.

Recommended Guides