PX to REM Converter

Convert pixel values to rem and em for CSS, and back.

PX to REM Converter tool

Convert
px
—
Result
—
em (parent at root size)
—
Points and percent
—
CSS

About the PX to REM Converter

Designs are drawn in pixels, but rem units let text and spacing scale with the reader's browser settings, which matters for accessibility. This px to rem converter divides by the root font size, 16 px by default, so 24 px becomes 1.5 rem and 14 px becomes 0.875 rem. It converts rem back to pixels, shows points and percentages and provides a conversion table you can copy into CSS.

rem = px ÷ root font size, where the root is the font size of the html element, 16 px by default in every major browser. em works the same way but relative to the parent element's font size, so it equals rem only when the parent uses the root size. Going back, px = rem × root. One CSS pixel is 0.75 pt, and 100% of the root font size equals 1 rem.

Example: 24 px is 24 ÷ 16 = 1.5 rem at the default 16 px root, and 12 px is 0.75 rem. If a site sets html { font-size: 62.5% } to make the root 10 px, 24 px becomes 2.4 rem. 1.25 rem at a 16 px root is 20 px.

Avoid setting the root font size in pixels, because that overrides the user's chosen text size; use a percentage if you change it at all. For other CSS tools see the CSS formatter and CSS minifier, and to convert between other units the unit converter.

How to use the PX to REM Converter

  1. Choose the directionPixels to rem, or rem to pixels.
  2. Enter the valueSuch as 24 px or 1.5 rem.
  3. Set the root font size16 px unless your CSS changes it.
  4. Copy the resultUse the CSS line or the table.

PX to REM Converter features

  • px to rem and em
  • rem back to px
  • Any root font size
  • Points and percent
  • CSS line to copy
  • Table of common sizes
  • Instant results

Common uses

  • Converting design mockups to CSS
  • Building accessible type scales
  • Spacing systems in rem
  • Refactoring pixel-based stylesheets
  • Learning CSS units

Rem units in practice: converting a type scale, fluid headings with clamp, borders, line height, readable widths and Urdu text

By the FreeToolsWorld editorial team · Updated November 2026 · How we write and check our guides

Converting pixel values to rem is the first step in building interfaces that respect each visitor's chosen text size. The harder questions come next: which values should stay in pixels, how to make headings fluid without breaking zoom, and how to keep long text readable. This guide converts a complete type scale, shows a fluid heading that still responds to text-size settings, and covers borders, line height, spacing, line length and the extra room Urdu script needs.

A worked example: converting a type scale

A design file uses font sizes of 12, 14, 16, 18, 20, 24, 32 and 40 pixels. At the default 16-pixel root, these become 0.75, 0.875, 1, 1.125, 1.25, 1.5, 2 and 2.5 rem. Defining them once as CSS custom properties, such as --text-sm: 0.875rem;, keeps every component consistent and lets the whole scale change in one place.

Fluid headings that still zoom

Headings that grow with screen width are often written using viewport units alone, but text sized only in vw ignores the user's text-size setting and barely changes when they zoom. Combining units keeps both behaviours: font-size: clamp(1.5rem, 1rem + 2vw, 2.5rem); grows smoothly between a minimum and maximum, and the rem parts still respond to the visitor's settings. This approach helps meet accessibility guidance that text should resize to 200 percent without loss of content.

Testing with larger text

Set the browser's default font size to 20 or 24 pixels and reload your pages. Layouts built in rem grow gracefully, while components with fixed pixel heights clip or overlap their text. Many visitors, including older users and people with low vision, browse with larger text permanently, so this test reveals problems real people face.

Borders and fine lines

Hairline borders and dividers usually look best in pixels. A border of 0.0625rem equals 1 pixel at the default size but becomes a fraction at other sizes, which browsers may round unpredictably or render blurred. Keeping 1-pixel borders in px while sizing text, spacing and containers in rem is a common and sensible split.

Line height without units

Line height works best as a plain number, such as line-height: 1.5, which multiplies each element's own font size. A fixed line height in rem or px stays the same when a heading or a user's text size grows, squashing lines together. Unitless values keep text comfortable at every size.

Spacing scales

Many design systems use spacing steps of 0.25rem, which is 4 pixels at the default size, giving a consistent rhythm of 4, 8, 12, 16 and 24 pixels. Because the steps are in rem, padding and gaps grow with text, so buttons and cards keep their proportions when visitors enlarge text.

Readable line length

Long lines of text are tiring to read. Limiting paragraph width with the ch unit, for example max-width: 65ch;, keeps lines at roughly 60 to 75 characters regardless of font size. As text grows, the column widens with it, so the line length stays comfortable.

Urdu and Nastaliq text

Nastaliq fonts used for Urdu have tall ascenders and deep descenders, so they usually need a noticeably larger line height than English text to avoid letters colliding between lines. Many Urdu sites also set Urdu text slightly larger than Latin text at the same nominal size. Testing real Urdu paragraphs at several sizes, rather than single words, shows whether the spacing works.

Common mistakes

  • Sizing headings in viewport units alone, so zoom barely affects them.
  • Using fixed pixel heights for components that contain text.
  • Converting hairline borders to fractional rem values.
  • Setting line height in fixed units.

Related tools

To keep images and video in proportion, use Aspect Ratio Calculator. To style corners, try Border Radius Generator, and to check text colours remain readable, Color Contrast Checker.

Icons that match their text

SVG icons sized with width: 1em; height: 1em; scale with the text beside them, so an icon in a button stays the same size as its label whether the visitor uses default text or enlarges it. Using em here, rather than rem, matches the icon to the local font size, which is exactly what inline icons need.

Tap targets

Buttons and links must be easy to tap. Accessibility guidance sets a minimum of 24 by 24 CSS pixels for most targets and recommends 44 by 44 for comfortable use. Setting a minimum height such as 2.75rem, which is 44 pixels at the default size, keeps targets large enough and lets them grow when visitors increase their text size.

Converting an existing site

Convert in stages rather than all at once. Start with font sizes, then padding and margins, and leave borders and shadows in pixels. Search the stylesheet for fixed heights on elements containing text, since these are the most likely to break. Comparing screenshots before and after each stage catches unintended changes early.

Privacy

Conversions happen in your browser. Nothing you enter is sent anywhere or stored.

Frequently asked questions

How do I convert px to rem?

Divide the pixel value by the root font size. With the default 16 px root, 32 px is 2 rem, 20 px is 1.25 rem and 14 px is 0.875 rem.

How do I convert rem to px?

Multiply the rem value by the root font size. 1.5 rem is 24 px and 0.5 rem is 8 px at the default 16 px root.

What is the difference between rem and em?

rem is relative to the root html element's font size; em is relative to the font size of the element's parent. Nested em values compound, while rem values stay consistent.

What is the default root font size?

16 pixels in all major browsers, unless the user changes their browser's text size setting. Using rem means your design respects that setting. Designers often keep 16 px as the base of their type scale.

Why use rem instead of px?

Rem sizes scale when users enlarge their browser's default text size, which helps people with low vision. Pixel sizes ignore that setting, although browser zoom still scales them.

What is the 62.5% trick?

Setting html { font-size: 62.5% } makes the root 10 px by default, so 1.6 rem is 16 px, which makes mental maths easier. It still respects user settings because it is a percentage.

How many points is 16 px?

12 pt, because one CSS pixel is 0.75 of a point. Points are mostly used for print stylesheets. In the other direction, 1 pt is 1.333 px, so 24 pt is 32 px.

Should media queries use rem or em?

Em is the usual choice for media queries, because browsers treat em in media queries consistently with the user's default font size, including in Safari. 48em is 768 px by default.

Can I use rem for padding and margins?

Yes. Spacing in rem scales with the text when users change their default font size, which keeps layouts balanced. Many design systems use a 4 px or 8 px grid expressed in rem, such as 0.5rem, 1rem and 1.5rem.