When rem is the better unit
Use rem for font sizes, and often for spacing, so a layout scales when someone raises their browser's default text size. Pixels stay fixed regardless of that setting. This matters for readability: people who increase their default size expect text, and the space around it, to grow.
Worked example with a 16px root: 14px is 0.875rem, 16px is 1rem, 18px is 1.125rem, 32px is 2rem. Writing them as rem lets one change to the root size rescale the whole design.
- Use em for properties that should scale with the element's own text, such as padding on a button.
- Use rem for global type scales and layout spacing.
- Media queries in em or rem also respond to the user's font size, in browsers that resolve them against the default size.