WorkbenchFree. No account.

CSS / TOOL 02

PX to REM

Convert pixels into root-relative CSS units. Use the actual root size, inspect the arithmetic and copy the value for your layout.

See a worked example
LIVE WORKSPACEInputs stay in this browser
Local input processingNo registrationPrivacy choices ↗

Understand the result

One pixel value, two root sizes

24px / 16px = 1.5rem
24px / 20px = 1.2rem

The root size is an input, not a universal constant. If the same 1.5rem is later rendered with a 20px root, it becomes 30px. The tool does not change your page root or override reader preferences.

Check the rendered layout

Inspect the computed font size on the html element in your project. Test the result with real content and browser zoom. Negative results can suit margins, but do not use negative padding or font sizes.

What this tool can and cannot tell you

REM values are relative to the computed font size of the root html element. At a 16px root, 24px is 1.5rem; at 20px it is 1.2rem. Relative units alone do not guarantee accessibility: test browser zoom and real content. Negative values suit margins, not font sizes.

Common questions

Is 16px always the root font size?

No. Read the computed html font size for the page you are changing. The converter lets you set that value explicitly.

What is the difference between rem and em?

REM uses the root font size. EM depends on the relevant element's font size and the property being evaluated; nested rules can behave differently.

Can I convert a negative value?

Yes, when the destination CSS property allows it, such as certain margins. The root size must remain positive.

Worked examples are synthetic. No customer outcome or saving is implied. Content by Orr Yoffe.

Twelve Tools directory

TheDevToolsDir

Related tool: Private JSON Formatter & Validator — Local Browser Tool

Reproduce a known result

1.2 rem. The CSS file assumes the page already has a computed 20px root; it does not override browser preferences.

Load 24px at a 20px root · Download synthetic example

Examples and troubleshooting

REM conversion is division: rem = pixels ÷ root font size in pixels. The important input is the computed font size of the root html element. A convenient 16px assumption is not a measurement of every page.

PX to REM conversion with 16px and 20px root sizes

Privacy

Your tool inputs are processed locally in your browser. Read the privacy policy and manage analytics using the privacy settings below.