FiFont
← All guides

Web design

Convert px to rem responsibly

Convert design sizes using the actual root font size.

1. Inspect the root

Check the computed root font-size of the actual document. Do not assume it is always 16px.

2. Calculate the ratio

Divide pixels by the root size; 24/16 is 1.5rem. At a 20px root that same value becomes 30px.

3. Apply to roles

Use scalable sizes when appropriate; adjust line boxes and containers to accommodate changes.

4. Test user settings

Increase default font size or zoom and check text, wrapping, navigation and visible controls.

Check root-size assumptions

Enter 24px and a root size of 16px into the Pixels to rem tool. The result is 1.5rem. In your page, change the root font size to 20px and inspect that 1.5rem resolves to 30px. Test the same heading in a narrow card without changing the container to a fixed height.

Common pitfall

A CSS pixel is not automatically a physical device pixel, and a rem is not always 16px. Read computed styles in the actual document; respect user size settings.

Convert pixels to rem →

Continue learning

Typography reference with visual examples →