CSS Units Guide: px vs rem vs em and Fluid clamp()
When to use px, rem, em, and viewport units, plus how fluid clamp() scales typography cleanly without breakpoints.
Updated 2026-11-28
Why rem is the default for typography
`rem` scales relative to the root `<html>` font size (16px by default). When a user increases their browser default font size for readability, `rem` typography and spacing scale respectfully while `px` stays fixed.
When em and px still belong
Use `px` for hairline borders (`1px`) and fixed-size icon strokes. Use `em` when a component’s padding or icon spacing should scale proportionally with its own local `font-size`.
Fluid scaling with clamp()
`clamp(min, preferred, max)` interpolates smoothly between a minimum and maximum size across viewport widths using a linear `rem + vw` preferred expression.
Try the related tools
PX to REM & Fluid Clamp Calculator
Convert px, rem, em, pt, vw, vh and % with Tailwind scale, fluid clamp() and type scales.
CSS Formatter & Minifier
Format or minify CSS/SCSS, sort properties, compute specificity and convert to JS or Tailwind.
Responsive Breakpoint Tester
Inspect active Tailwind/CSS breakpoints, preview responsive grids and generate media queries.