Skip to content

REM vs PX: which CSS unit should you use for your site?

Webflow7 min read

James BrunettoCo-fondateur & CEO

Synqro thumbnail: comparing the px unit and the rem unit in CSS

In CSS, px is a fixed unit and rem is a unit relative to the font size of the root element (the html tag). The simple rule: use rem for text and spacing, so you respect the font size the user has chosen, and px for borders, shadows and small details that need to stay fixed.

With the browser default size (16 px), 1rem equals 16px. The conversion fits on one line: rem = px ÷ 16.

This guide explains the differences between the two units, their impact on accessibility, how to convert, and how to set them up in Webflow.

Explore this post with…

REM vs PX: the short answer

Px and rem are not rivals: they meet different needs. The table below sums up how they differ in practice.

Criterionpxrem
Type of unitAbsoluteRelative to the root font size (html)
Follows browser zoomYesYes
Follows the font size set by the userNoYes
Recommended useBorders, shadows, fixed detailsText, margins, padding, component sizes
CalculationDirectpx ÷ root font size (16 by default)
Comparison of the rem and px CSS units

What is a pixel (px) in CSS?

Px is an absolute length unit in CSS. Contrary to popular belief, a CSS px is not a physical screen pixel: the MDN documentation on CSS lengths points out that it equals 1/96th of an inch. The browser adapts it to the screen density: on a high-resolution screen, 1 CSS px covers several physical pixels.

What matters in practice: a size in px gets bigger when the user zooms in on the page, but it ignores the default font size they chose in their browser settings. That is where the difference with rem comes in.

Its strengths: you can read values straight from the Figma mockup, and you get exact control over fine details (a 1px border, a shadow). Its limit: text in px stays the same size for someone who has asked for larger characters.

Table of the pros and cons of the px unit

What is rem (root em)?

Rem (root em) is a relative unit equal to the font size of the document's root element, the html tag. If the root is set to 16 px, 1rem equals 16px and 1.5rem equals 24px. If the user changes their default font size to 20 px, 1rem equals 20px and everything set in rem grows in the same proportion.

Do not confuse rem and em. Em depends on the font size of the parent element (or of the element itself), which creates cascading effects when elements are nested. Rem has only one reference, the root, so it stays predictable everywhere on the page.

Table of the pros and cons of the rem unit

Why rem is more accessible than px

Browsers let users change the default font size, for example in Chrome under Settings, then Appearance, then Font size. People with low vision and many older adults use this setting. Text set in rem respects it, text set in px does not.

WCAG 2.2 success criterion 1.4.4 (W3C) requires that text can be resized up to 200% without loss of content or functionality. Zoom is technically enough to meet this criterion, but rem goes further: it applies the user's preference without them having to zoom on every site. For the rest of the best practices, see our guide to web accessibility.

Webflow takes the same approach: the FlowKit documentation, for its official CSS framework, makes rem the main unit for typography and spacing, and keeps px for borders and shadows, "to be used sparingly".

When to use px, rem or another unit?

ElementRecommended unitWhy
Text sizeremFollows the font size chosen by the user
Line heightUnitless (1.5, for example)Stays proportional to the text size
Section margins and paddingremSpacing grows with the text
Button padding, icon sizeemFollows the size of the button text
Borders and shadowspxA 1px detail must stay sharp
Container width% with a max-width in remAdapts to the screen without becoming hard to read
Full-screen sectionvh or dvhRelative to the window height
Grid columnsfrDistributes the available space

The convention we apply at Synqro on our Webflow builds fits in one sentence: text and spacing in rem, borders and shadows in px, widths in percentages capped by a max-width. A written convention matters more than the unit itself, because it keeps a site from mixing the two at random as updates pile up.

How to convert px to rem

The formula: value in rem = value in px ÷ root font size. With the default value of 16 px, 24px ÷ 16 = 1.5rem. Here are the most common conversions.

pxrem (root at 16 px)Typical use
12px0.75remFine print, captions
14px0.875remSmall text
16px1remBody text
18px1.125remIntro text
20px1.25remH4 heading
24px1.5remH3 heading
32px2remH2 heading
48px3remH1 heading
64px4remLarge section spacing

The 62.5% trick: useful, but with caution

Some developers write html { font-size: 62.5%; } so that 1rem equals 10px with the default setting. The math gets simpler (24px = 2.4rem), and the user's preference is still respected, because the value is expressed as a percentage.

Two precautions: redefine the body size (1.6rem to get back to 16 px), and check third-party components that assume 1rem = 16px. Above all, never write html { font-size: 10px; }: a px value on the root overrides the user's preference and cancels out the point of using rem.

Using rem in Webflow

The Webflow Designer uses px by default, but every size field accepts other units. Here is the method we follow.

  1. Enter the unit. In the Style panel, type the value with its unit directly (1.125rem) or click the unit shown on the right of the field and choose REM.
  2. Set the base. Style the Body (All pages) tag and the H1 to H6 tags in rem, so the whole site inherits them.
  3. Create size variables. In the Variables panel, create your text and spacing sizes in rem. According to Webflow's help center (updated in June 2025), a variable can contain clamp(), calc(), min(), max() or color-mix(). For example, clamp(2rem, 1.5rem + 2vw, 3.5rem) for a fluid heading.
  4. Change the root if needed. Webflow has no dedicated setting for this: you need an html { font-size: ... } rule in custom code. Use a percentage rather than a px value.
  5. Test. Set your browser font size to "Very large" and browse the pages: no text should overflow or be cut off.
Choosing between rem and px depending on the element to style

Rem does not solve everything in responsive design: you still need to adapt layouts at each breakpoint. See our guide to building a responsive site in Webflow and our article on the Client-First method, which structures the classes and sizes of a Webflow project.

Common mistakes with px and rem

  • Setting the html tag size in px, which overrides the user's preference.
  • Writing all text sizes in px because the Figma mockup is in px.
  • Nesting em sizes, which multiply from one level to the next.
  • Giving a text block a fixed height in px: the text overflows as soon as it is enlarged.
  • Mixing units without a written convention, which makes the site hard to maintain.

Synqro, a Webflow Premium Partner founded in 2019, builds Webflow sites with these conventions from the very first page. If your current site mixes units with no logic, our Webflow team can audit and rework your style foundation.

Frequently asked questions

Let’s build something great

Book a call