In short
px, %, rem, em, vh, ch. Picking the right unit is the difference between a layout that bends nicely on every screen and one that breaks the moment someone zooms.
CSS sizes can be absolute like px or relative like %, em, rem, vw and vh. Relative units help text and layouts scale with the user's settings and screen size.

Think of it like this
Measuring in a home kitchen
Mummy says 'one katori rice' (relative to the katori) or 'a pinch of salt' (relative to the dish). Rarely '87 grams'. rem and em are like the katori: sizes relative to something else. px is the exact gram scale.
Watch it happen
Follow one user setting through rem and em
1/5A user changes their browser's default text size to 20px.
The big ideas
What you need to know
px is fixed
Fine for borders and small details. For font sizes it ignores the reader's preferred text size.
rem follows the root
1rem equals the root (html) font size, usually 16px. If a user sets bigger text, everything in rem grows with it.
em follows the parent
1em is the current element's font size. Good for padding on buttons, but nested ems multiply quickly.
Viewport and ch
vw and vh are percentages of the screen. dvh fixes mobile address bar jumps. ch is roughly one character wide.
See it in code
Walk through the code
1html { font-size: 100%; } /* respects user settings */2 3body { font-size: 1rem; } /* usually 16px */4h1 { font-size: 2.5rem; }5 6.btn {7 font-size: 1rem;8 padding: 0.5em 1em; /* grows if the font grows */9 border: 1px solid; /* px is fine here */10}11 12.hero { min-height: 100dvh; } /* full screen, even on mobile */13.article { max-width: 65ch; } /* comfy line length */1/4100% means 'whatever the user's browser setting is', usually 16px.
rem for text, em for spacing that should scale with text, px for hairlines, and viewport units for full-screen sections.
Save yourself the pain
Common mistakes
Oops
Setting html { font-size: 10px; } to make rem maths easy.
Do this instead
That overrides users who need bigger text. Keep 100% and get used to 1rem = 16px.
Oops
Using 100vh for a mobile hero and getting a jumpy bottom edge.
Do this instead
Use 100dvh, which adjusts as the mobile address bar shows and hides.
Your mission
The zoom test
Quick check
A user sets their browser's default text size to 20px. Which font-size grows with that setting?
Go deeper
- 1Use rem for font sizes and spacing so the page respects browser font settings.
- 2Build a full-screen hero section with height: 100vh and test it on a phone.
- 3Change your browser's default font size and see which parts of your page scale.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.