About the PX to REM Converter
This tool converts a CSS pixel length into a rem value based on the root font size you enter. It is useful for web designers and front-end developers who want scalable spacing, font sizes, or layout measurements in rem units.
How to use this calculator
- Enter the pixel value you want to convert in the Pixel value field.
- Enter the Root font size in pixels, or leave it at 16px for the common browser default.
- Read the Result field to get the equivalent rem value.
- Copy the CSS value if you want a ready-to-use font-size declaration.
- Use the common px table to compare other pixel values at the same root size.
How it works
The calculator uses the standard CSS relationship between pixels and rem units. A rem value is measured relative to the root element’s font size, usually the font size set on the html element.
The formula is rem = pixels ÷ root font size. For example, if the pixel value is 24 and the root font size is 16, the conversion is 24 ÷ 16 = 1.5rem.
If an invalid pixel value is entered, the calculator treats it as 0. If the root size is missing or invalid, it uses 16px, and it prevents the root size from going below 0.01px to avoid division by zero.
Example calculation
If you enter 24px as the pixel value and 16px as the root font size, the calculator divides 24 by 16. The result is 1.5rem, so the CSS value shown is font-size: 1.5rem;.
Frequently asked questions
What is the default root font size for rem conversions?
Most browsers use 16px as the default root font size unless it is changed in CSS.
How do I convert px to rem manually?
Divide the pixel value by the root font size. For example, 32px divided by 16px equals 2rem.
Why use rem instead of px in CSS?
Rem units scale with the root font size, which can make typography and spacing more consistent and more responsive to user settings.
Does this calculator convert all CSS properties?
It performs the numeric px-to-rem conversion and displays a font-size example, but the same rem value can be used for other CSS properties where rem units are valid.