CSS units at a glance
| Unit | Relative to |
|---|---|
| px | CSS pixels (1/96 inch) |
| rem | Root (html) font size |
| em | The element's (parent's) font size |
| % | The parent value (for font-size: the parent's font size) |
| vw / vh | 1 % of the viewport width / height |
| pt | Points: 1pt = 1.333px (print) |
Quick reference (16 px root)
12px = 0.75rem · 14px = 0.875rem · 18px = 1.125rem · 20px = 1.25rem · 32px = 2rem.
Set your own root font size and viewport to match your design. The em result assumes the parent uses the root font size.
Frequently asked questions
Why use rem instead of px?
rem respects the user's preferred font size in the browser, which makes text accessible and layouts scale consistently.
What is the difference between em and rem?
rem is always relative to the root font size; em is relative to the current element's font size and can compound when nested.
How many px is 1pt?
1pt = 1.333px in CSS (96px per inch, 72pt per inch).

