Guide
PX to REM - sizing CSS that respects users' font settings
Designs are usually specified in pixels, but stylesheets work better in rem. A rem is a multiple of the root font size: with the browser default of 16 px, 1rem = 16 px and 1.5rem = 24 px. This converter translates in both directions for any root size, with a reference table for the values you use most.
Converting
- Type a pixel value to get rem, or press swap to type rem and get pixels.
- Set the root font size if your site changes it (the default is 16 px). It’s remembered for next time.
- Copy the result with one click. Values are rounded to at most four decimals, such as 0.875rem or 0.0625rem.
Formula: rem = px ÷ root size, and px = rem × root size.
Common values at 16 px
| Pixels | rem | Typical use |
|---|---|---|
| 12 px | 0.75rem | Captions, labels |
| 14 px | 0.875rem | Small text, buttons |
| 16 px | 1rem | Body text |
| 18 px | 1.125rem | Large body, lead text |
| 20 px | 1.25rem | Small headings |
| 24 px | 1.5rem | H3 |
| 32 px | 2rem | H2 |
| 48 px | 3rem | H1, hero titles |
The table on the page recalculates these for whatever root size you set.
Why rem matters
Browsers let people choose a larger default font size, and many do, especially people with low vision and older readers. Font sizes written in rem scale with that setting. Sizes in px stay fixed, so the person’s preference is ignored. Page zoom enlarges both, but font-size settings are a separate, widely used preference.
Using rem for type helps meet WCAG’s Resize Text requirement and makes the whole layout scale consistently when spacing uses rem too.
When to keep px
- Borders and hairlines: a 1 px border should stay 1 px.
- Box shadows and small decorative details.
- Media query breakpoints are a matter of choice; em-based breakpoints respond to font-size settings in some browsers, which can be what you want.
rem vs em
- rem is relative to the root (
html) font size, the same everywhere on the page. Predictable. - em is relative to the current element’s font size, so it compounds: 1.2em inside 1.2em is 1.44 times the root. Useful for padding that should grow with a button’s own text size.
The 62.5% trick
Some sites set html { font-size: 62.5%; } so 1rem = 10 px and the math becomes trivial (24 px = 2.4rem). It still respects user preferences, but body text must then be set explicitly (body { font-size: 1.6rem; }), and third-party components that expect 16 px can render too small. Keeping 16 px and converting with a tool, or defining CSS variables such as --space-4: 1rem, avoids those side effects.
A simple scale
Many design systems use multiples of 4 px for spacing: 4, 8, 12, 16, 24, 32, 48 and 64 px, or 0.25, 0.5, 0.75, 1, 1.5, 2, 3 and 4rem. Defining them once as variables keeps spacing consistent and makes the conversion a one-time job.
Who converts px to rem
- Front-end developers turn design specs in pixels into accessible rem values.
- Designers handing off to developers provide sizes in both units.
- Students learn responsive and accessible CSS.
- Teams building design systems define spacing and type scales.
A complete example: a type scale from a design file
A design uses 14, 16, 20, 24 and 32 px:
- Convert at a 16 px root: 0.875, 1, 1.25, 1.5 and 2rem.
- Define them as variables, such as
--text-sm: 0.875rem. - Test by changing the browser’s default font size to Large: text grows, and the layout should still hold.
Tips
- Keep borders in px; use rem for text and spacing.
- Agree on one root size for the whole project.
Related tools
- Box Shadow Generator and CSS Gradient Generator for other CSS values.
- Unit Converter for physical units such as centimeters and inches.
- Contrast Checker for the other half of readable text: color.
Checked against the current version of the PX to REM on .

