PX to REM Converter 2026 | Convert Pixels to CSS REM Online

PX to REM Converter

Convert pixels to REM instantly using your preferred root font size.

Default browser root font size is typically 16px.
Converted REM Value
1rem
16px = 1rem

Convert pixel measurements into CSS rem units with this PX to REM Converter. Enter the pixel value you need, choose the root font size used by your website, and select Convert to REM. The result appears in rem, ready to copy into your stylesheet.

The converter is useful when translating design measurements into CSS for font sizes, spacing, padding, and other dimensions. It starts with a common 16px root font size, but you can change that value to match your project rather than relying on an assumption.

Quick Answer: How Do You Convert PX to REM?

Divide the pixel value by the root element’s font size in pixels. At a 16px root size, 24px is 1.5rem because 24 ÷ 16 = 1.5. At an 18px root size, the same 24px is approximately 1.3333rem. The correct result depends on the base size you use.

What Does the PX to REM Converter Do?

The tool takes a value expressed in CSS pixels (px) and returns its equivalent in rem (root em). A rem is a CSS length unit based on the computed font size of the document’s root element, usually <html>. For example, if the root font size is 16px, then 1rem equals 16px and 2rem equals 32px.

Unlike a direct pixel value, a rem-based dimension changes when the root font size changes. That can be especially useful for typography and spacing designed to respect a visitor’s font-size preferences. It does not mean a rem value automatically adjusts to screen width; viewport-based sizing uses different CSS units.

How to Use the PX to REM Converter

  1. Enter Pixels (PX): Type the measurement you want to convert into the Pixels field. For example, enter 24 for 24px.
  2. Set Root Font Size: Keep 16 if your project uses a 16px root, or enter the actual root size, such as 18.
  3. Convert: Select Convert to REM to calculate the matching rem value.
  4. Read the result: The Converted REM Value panel shows the rem number and a short explanation identifying the pixel value and base size used.
  5. Copy or start again: Select Copy Result to reuse the value in CSS, or Reset to return to the starting values.

For a quick check, leave the default inputs at 1px and 16px. The displayed result should be 0.0625rem, since 1 ÷ 16 = 0.0625.

PX to REM Formula

Formula: REM = Pixel value (px) ÷ Root font size (px)

The pixel value is the size you are converting. The root font size is the computed font size of the page’s <html> element, expressed in pixels. Both inputs use px, so the division produces a number that you can write with the rem unit.

Example with a 16px root: 20px ÷ 16px = 1.25rem.

Example with an 18px root: 36px ÷ 18px = 2rem.

To perform the calculation in the opposite direction, multiply the rem value by the root font size. Our separate REM to PX Converter is intended for that reverse conversion.

PX to REM Conversion Table (16px Root Font Size)

Use this reference for common CSS measurements. Every value below assumes the root font size is exactly 16px; change the Root Font Size field in the tool when your website uses a different value.

Pixels (px) REM
1px 0.0625rem
4px 0.25rem
8px 0.5rem
10px 0.625rem
12px 0.75rem
13px 0.8125rem
14px 0.875rem
16px 1rem
18px 1.125rem
20px 1.25rem
24px 1.5rem
28px 1.75rem
32px 2rem
40px 2.5rem
48px 3rem
64px 4rem

What Happens If the Root Font Size Changes?

The same rem value represents a different number of pixels when the root font size changes. Suppose a design calls for 24px of padding. With a 16px root, you would use 1.5rem. With a 20px root, 24px is 1.2rem. If you keep the CSS value at 1.5rem instead, its computed length becomes 30px when the root grows to 20px.

A typical browser default is 16px, but it is not universal. A user may choose a different font size in their browser, and your website may define another size on html. Check the actual computed root font size if you need to match an existing page precisely.

For projects intended to follow user font preferences, setting the root font size as a percentage rather than hard-coding it in pixels can be helpful. For example, html { font-size: 100%; } generally retains the user’s default font size.

Practical CSS Example: Typography and Spacing

Imagine a card design with 14px body text, 24px padding, and an 8px corner radius. With a 16px root, the corresponding rem values are 0.875rem, 1.5rem, and 0.5rem:

.card {
  font-size: 0.875rem;
  padding: 1.5rem;
  border-radius: 0.5rem;
}

This makes the card’s measurements depend on one shared root font size. If that size changes, these rem-based values scale together without editing each declaration. You can use the converter whenever design specs are supplied in pixels but your CSS system uses rem.

PX vs REM vs EM: Which Unit Should You Use?

CSS Unit What Determines Its Size? Typical Use
px A CSS reference pixel, independent of the root font size Fixed-width details and explicit design measurements
rem The root element’s font size Typography and consistent page-wide spacing
em The element’s own font size for most properties; its inherited font size when setting font-size Spacing or sizes intended to scale with an individual component

REM is often convenient for a shared spacing or type scale, while em is useful when dimensions should depend on a component’s font size. Pixels remain suitable when a measurement should not change with the root font size. None of these choices alone guarantees a responsive layout.

If you need an element’s size to depend on the viewport width rather than the root font size, use our PX to VW Converter to calculate that different CSS unit.

When Is Converting Pixels to REM Useful?

  • Implementing UI designs: Translate pixel-based typography, padding, and spacing specifications into rem-based CSS declarations.
  • Maintaining a design system: Express common sizes relative to one root value rather than recalculating them in multiple components.
  • Updating existing styles: Convert selected fixed measurements when a stylesheet moves toward font-relative sizing.
  • Checking accessibility behavior: Understand how text and spacing based on rem will change if the root font size increases.

If your task is to express a measurement as a percentage of a containing width instead, the PX to Percentage Converter is a more appropriate calculation, provided you know the reference dimension.

Can You Convert PX to REM in JavaScript?

Yes. JavaScript can perform the same division, provided you supply the intended root font size. This small example uses a 16px default:

function pxToRem(px, rootFontSize = 16) {
  return `${px / rootFontSize}rem`;
}

pxToRem(24); // "1.5rem"

For a page whose computed root size is different, pass that value as the second argument. This code example explains the calculation; the online converter itself does not need JavaScript input or code snippets from you.

Common Mistakes and Helpful Tips

  • Assuming every root is 16px: Check your project’s actual value, especially when an existing stylesheet sets a custom html font size.
  • Confusing rem with em: REM uses the root size; em often changes with the element or its parent, depending on the CSS property.
  • Expecting rem to follow screen width: REM follows root font size, not viewport width. A responsive layout may use several CSS techniques together.
  • Rounding too soon: Keep enough decimal places when converting uncommon values, then choose sensible precision for your stylesheet.
  • Overriding user preferences: Consider how a fixed pixel font size on the root affects people who have chosen a larger browser default.

What This Conversion Does Not Tell You

The tool calculates a numerical equivalence for the root size you enter; it does not inspect your website’s live CSS, detect a user’s browser settings, or preview the rendered design. The result also does not account for layout constraints such as minimum widths, text wrapping, or media queries. Validate the finished page at different zoom levels, font-size preferences, and viewport widths when those behaviors matter.

Also remember that a CSS pixel is a reference unit, not necessarily one physical display pixel. Converting a CSS size to rem does not measure hardware resolution or image quality.

Convert Your Next CSS Measurement

Enter the pixel value and the root font size used by your project, select Convert to REM, and copy the result into your CSS. For common values, the 16px reference table above provides a quick cross-check; for a custom base, use the converter’s Root Font Size field.

Frequently Asked Questions

How many rem is 1px?

At a 16px root font size, 1px equals 0.0625rem. If your root size differs, divide 1 by that size to get the correct result.

What is 16px in rem?

16px equals 1rem when the root font size is 16px. With an 18px root, 16px is approximately 0.8889rem, so the base value matters.

How do I convert 14px or 20px to rem?

Using the common 16px root, 14px equals 0.875rem and 20px equals 1.25rem. Enter either pixel value into the converter if your project uses another root size.

Is 1rem always 16px?

No. A 16px root is common, but 1rem always corresponds to the root element’s computed font size. For example, when the root is 20px, 1rem equals 20px.

Does using rem automatically make a website responsive?

No. REM-based values respond to changes in the root font size, not automatically to viewport width. Responsive design may also require flexible layouts, appropriate image sizing, and media or container queries.

What is the difference between rem and em in CSS?

REM is relative to the root element’s font size. EM is relative to an element’s own font size for many properties, while an em value used for font-size is relative to the inherited font size. This can produce different sizes in nested components.

Can I use a root font size other than 16px?

Yes. Enter the root size used by your website into the Root Font Size field before selecting Convert to REM. The converter applies that value to the calculation, so the output matches your selected base.

Useful CSS & Pixel Conversion Tools

If you are using the PX to REM Converter, these related tools can help with CSS sizing, responsive layouts, viewport units, and pixel-based web design calculations.