Skip to main content

Bidirectional PX - REM converter


Instantly convert _pixels_ (px) to _root em_ (rem) and rem to px (bidirectional) with this free online PX/REM calculator. The conversion is based on an adjustable default root font-size of 16 pixels.

Pixel value to be calculated to and from rem value. Based on the root font size.
Rem value to be calculated to and from pixel value. Based on the root font size.
Set the root font size for the calculations between pixels and rem.

About pixels (px) and root em (rem) #

The CSS absolute length unit px represents a fixed measurement based on device pixels, providing a precise and consistent size on screens and devices.

The CSS font-relative length unit rem refers to the font size of the root element and allows consistent scaling of elements throughout a document.

Both units, rem and px, work in conjunction by allowing designers to set sizes using the relative unit rem that adjusts according to the root font size and a fixed unit px that remains consistent regardless of scaling. Sizes set in rem dynamically adjust proportionally when the root font size changes, maintaining their relative ratios.

How to convert pixel values to rem values and vice versa? #

Converting pixel to rem #

  1. Determine the root font size in px (usually set in the <html> element).

  2. Divide the pixel value by the root font size to get the equivalent rem value.

PX to REM formula: #


Converting rem to pixel #

  1. Determine the root font size in px (usually set in the <html> element).

  2. Multiply the rem value by the root font size to get the equivalent pixel value.

REM to PX formula: #


Calculation examples #

If the root font size is set to 16px:

Converting 24px to rem: 2416=1.5rem

Converting 1.5rem to px: 1.5×16=24px

Remember that these conversions take into account the root font size, which can vary based on your design decisions. Also, precision might be needed for responsive designs to ensure proper scaling across different screen sizes.

FAQ's #

Most common questions and brief, easy-to-understand answers on the topic:

What is the difference between px and rem?

The primary difference between px and rem is that px is an absolute unit that remains fixed regardless of root font size changes, while rem is a relative unit that scales proportionally based on the root font size, making rem well-suited for responsive designs.

How does the root font size impact rem units?

The root font size directly affects rem units: any value specified in rem is calculated in relation to the root font size. Changing the root font size will cause all rem values to scale proportionally, ensuring consistent adjustments throughout the document.

Can I mix px and rem units in the same stylesheet?

Yes, you can mix px and rem units within the same stylesheet. This allows you to take advantage of the benefits of both, absolute (px) and relative (rem), units. For example, you might use px for fixed-size elements or precise layout details, and rem for typography and responsive components that need to adapt based on the root font size. Mixing these units gives you a balance between control and scalability in your design.

Further readings #

Sources and recommended, further resources on the topic:

“Many of our sentences could be improved by cutting them shorter. Out with the semicolons, in with the periods. Don't write one long sentence if you can say the same thing in two short ones.”

Rosalie Stemer, Editor at the San Francisco Chronicle, teaches copy editing at BerkeleyMathematical Writing - Seminar in Analysis, - UX quotes