What is the PX to REM Converter?
rem ("root em") is a CSS unit relative to the font size of the root <html> element, which is 16px in every major browser by default. So 1rem = 16px, 1.5rem = 24px and 0.875rem = 14px. The formula is simple: rem = px รท root font size.
Sizing text and spacing in rem instead of px respects the font size a visitor sets in their browser, an important accessibility requirement (WCAG 1.4.4 Resize Text). This converter works in both directions with any root size. The bulk converter rewrites every px value in a block of CSS, optionally keeping 1px borders and hairlines as pixels.
How to use the PX to REM Converter
- Check the root font size. It is 16px unless your CSS sets a different
html { font-size }. - Type a pixel value to get rem, or a rem value to get pixels.
- To convert a whole stylesheet, paste it under Bulk convert CSS and click Convert CSS.
Frequently asked questions
What is the difference between rem and em?
rem is relative to the root element's font size, so it is the same everywhere on the page. em is relative to the font size of the current element, so it compounds when elements are nested. rem is easier to reason about for most layouts.
Should I set html { font-size: 62.5% }?
That trick makes 1rem equal 10px for easier maths, but it changes every rem value on the page and can surprise third-party components. Keeping the default 16px and using a converter is usually safer.
Should borders be in rem?
Usually not. Thin borders are often kept at 1px so they stay crisp at any zoom level. That is why the bulk converter can skip 1px values.