Tech / PX to REM Converter
PX to REM Converter
Convert between px, rem, pt and percent for any root font size, or convert every value in a block of CSS in one go.
Convert one value
1rem equals the root font size, which is 16px in browsers unless a site changes it. em works the same way but is measured against the parent element's font size.
Common sizes
| px | rem | pt |
|---|
Convert a whole stylesheet
px, rem, em and pt explained
- px - a fixed CSS pixel.
- rem - relative to the root (
html) font size. With the usual 16px,1remis 16px and1.5remis 24px. - em - relative to the font size of the parent element, so it grows or shrinks with its surroundings.
- pt - a print unit: 1pt is 1/72 of an inch and 1px is 1/96 of an inch, so 12pt equals 16px.
Why use rem for text?
Many people make text bigger in their browser settings because it is easier to read. Sizes in rem grow with that setting, while sizes in px stay fixed. Using rem helps meet the accessibility rule that text can be enlarged to 200% without losing content - see WCAG resize text.
When is px still fine?
For thin borders, outlines and shadow offsets, px is fine, because a 1px line should stay 1px thin. That is why the stylesheet converter has an option to leave 1px values alone.
rem or em for spacing?
Use rem for most spacing and layout, so everything follows the root size. Use em for things that should grow with their own text, such as the padding inside a button.
What if my site changes the root size?
Some sites set html { font-size: 62.5%; } so that 1rem equals 10px. If yours does, type 10 as the root font size above, and every conversion will match your site.