Toolpuffin

    Loading...

    Up and down to choose, Enter to open, Esc to close.

    px vs rem in CSS: What Is the Difference and How to Convert

    Updated November 2026

    Written by the Toolpuffin team. Tools in this guide are tested in the browser.

    In CSS you can size text and spacing in pixels (px) or in rem. Both work, but they behave differently when a visitor changes their font size. This guide explains the difference, gives a conversion table and shows how to convert your own values.

    Try the tool: PX to REM Converter

    The difference

    A pixel is a fixed unit. The rem unit is relative: 1rem equals the font size of the root element, and in browsers that is 16px unless it is changed. Sizes in rem therefore grow when the root font size grows.

    Source: web.dev: Sizing units

    Why rem is often preferred for text

    Relative units follow the visitor's settings better, so text sized in rem can respect a larger default font size that a person has chosen. Stanford's accessibility guidance advises relative units for font sizes to support zoom and user settings.

    Source: Stanford: Absolute vs relative sizes

    Conversion table for a 16px base

    pxrem
    12px0.75rem
    14px0.875rem
    16px1rem
    20px1.25rem
    24px1.5rem
    32px2rem

    The formula is rem = px divided by the base font size. If your root font size is not 16px, divide by that number instead.

    Convert your own values

    1. Open the px to rem converter.
    2. Set your base font size, usually 16.
    3. Type a value, or paste a piece of CSS to convert every px value at once.
    4. Thin 1px borders can stay as they are.

    More guides