CSS Units (px, rem, em, vh, ch)
Never use raw pixels for font sizes again. Master relative scaling, accessible rem root calculations, viewport metrics (vh, dvh), and typographic ch constraints.
Why Professionals Build with `rem` Instead of `px`
If an elderly user increases their default browser font size from 16px to 24px for accessibility, font-size: 16px ignores their setting completely!
Only use px for: Thin 1px borders, subtle box-shadow offsets.
1rem equals the root <html> font size (default 16px).
If the user changes their browser preferences, all rem dimensions scale proportionally across the entire site!
See How Root Changes Propagate
Interactive Units Studio
Units & Functions
Play with clamp(), min(), and viewport units to build constraint-based sizing.
Try these
- Increase max to see upper bound loosen.
- Drop min to watch minimum size shrink on narrow viewports.
- Notice width uses min() to cap container across breakpoints.
Adjust min/max to see the clamped range. Width uses min() to cap the container across breakpoints.
.utility {
font-size: clamp(14px, 1vw + 1rem, 28px);
width: min(90vw, 640px);
}<div class="utility">Constraint-based sizing with clamp(), min(), and viewport units.</div>
15. Math Functions (calc, min, max, clamp)
Fluid typography, viewport constraints, and clamp() magic.