1. CSS Units Explained — px, rem, em, vw, and %

Before diving into px to rem conversion, it's worth understanding where rem sits in the full picture of responsive CSS units. Whether you're using a css unit converter, a px rem em converter, or calculating manually, knowing each unit's purpose makes you a far more effective CSS developer. CSS has two categories: absolute units and relative units.

UnitTypeRelative ToBest Used For
pxAbsoluteDevice pixels (fixed)Borders, shadows, icons, pixel-perfect details
remRelativeRoot element font size (html)Font sizes, spacing, layout — anything scalable
emRelativeParent element font sizeComponent-level spacing tied to local font size
%RelativeParent element dimensionWidths, heights, fluid layouts
vw / vhRelativeViewport width / heightFull-screen sections, fluid hero layouts
chRelativeWidth of the "0" characterProse containers, line length control
clamp()FunctionMin, preferred, max valuesFluid typography combining rem and vw

Of all these units, rem is the most important one to understand for modern, accessible, maintainable CSS — which is exactly why px to rem conversion is one of the most searched developer topics every month.

2. What Is rem in CSS?

rem stands for root em. It is a CSS length unit equal to the computed font size of the html (root) element. Unlike em, which is relative to the parent element and therefore cascades unpredictably through nested elements, rem always refers to a single, consistent value — the root font size.

16px
Default browser root font size — the base for all rem calculations
1rem
= 16px at default browser settings (can change with user preferences)
90,500
Monthly searches for "px to rem" — one of CSS's most-searched topics
WCAG 2.2
Accessibility standard that rem helps meet — pixel values can fail it
📌
rem vs em — The Key Difference

em compounds through nested elements — if a parent has font-size: 1.2em and a child also has font-size: 1.2em, the child ends up at 1.44× the root size (1.2 × 1.2). rem never compounds — every element using rem always calculates from the same root value, regardless of how deeply nested it is. This makes rem far more predictable and bug-free for design systems.

3. The px to rem Formula

Converting px to rem requires knowing one number: your root font size. The default browser root font size is 16px, and most developers leave it at that.

rem = px ÷ root font size
Default: rem = px ÷ 16  |  Reverse: px = rem × 16

Two of the most searched specific conversions are 16px to rem (answer: 1rem) and 24px to rem (answer: 1.5rem) — both divide by 16. This same css font size calculator logic applies to every value: divide your pixel number by your base font size. The Vicspot rem unit calculator handles any base size instantly — a true font size converter css developers can rely on daily.

Formula Examples at 16px Base

CalculationResultCommon Use Case
16px ÷ 161remBase body font size — 16px to rem = 1rem
14px ÷ 160.875remSmall text, captions
18px ÷ 161.125remSlightly larger body text
24px ÷ 161.5remH3 headings — 24px to rem = 1.5rem
32px ÷ 162remH2 headings
48px ÷ 163remHero headings, H1
64px ÷ 164remDisplay / large hero text
📐
Free px ↔ rem Calculator — Instant Conversion

The most complete css unit converter online — works as a px to rem converter, rem to pixel converter, rem unit calculator, and font size converter css. Enter any value, get the result instantly. Custom base font size supported. No login required.

Open Calculator →

4. Full px to rem Conversion Chart (16px Base)

This reference chart covers every common pixel value from 1px to 96px at the standard 16px root font size. Highlighted rows are the most frequently used values in real-world CSS.

px Valuerem ValueCommon Use
1px0.0625remBorders, dividers
2px0.125remThin borders
4px0.25remMicro spacing, border-radius
6px0.375remSmall gaps
8px0.5remPadding XS, gap-2 in Tailwind
10px0.625remSmall labels
12px0.75remCaption text, text-xs
14px0.875remSmall body text, text-sm
16px1remBase font size, text-base
18px1.125remLarge body text, text-lg
20px1.25remtext-xl, nav font size
22px1.375remMedium heading
24px1.5remH3, text-2xl, card title
28px1.75remtext-3xl, subheading
32px2remH2, text-4xl
36px2.25remtext-4xl alt
40px2.5remSection heading, text-5xl
44px2.75remLarge heading
48px3remH1 desktop, text-5xl
56px3.5remHero subheading
64px4remHero title, display text
72px4.5remLarge display
80px5remExtra large display
96px6remMassive hero text

Highlighted rows are the values you'll use in 90%+ of your daily CSS. Bookmark this page or use the px to rem tool for quick access.

5. rem vs px — Complete Comparison

The rem vs px css debate comes up in every serious front-end discussion. Developers also frequently search for a pixel to em converter alongside rem tools — but understanding the fundamental rem vs px difference first saves you from picking the wrong unit entirely. Here is the comprehensive comparison across every dimension that matters in production CSS:

✅ rem — Use For
  • Scales with browser font size preferences
  • Passes WCAG 1.4.4 (Resize Text) accessibility
  • Consistent across all nesting levels
  • Makes global rescaling trivial (change one root value)
  • Ideal for design tokens and systems
  • Fluid with clamp() and viewport units
  • Better developer ergonomics at scale
❌ px — Avoid For
  • Does not scale with user font preferences
  • Can fail WCAG accessibility audits
  • Requires manual math for global rescaling
  • Creates brittle, inflexible design systems
  • Ignores users who need larger text
  • Cannot participate in clamp() fluid scaling
  • More code changes for responsive breakpoints
PropertyrempxWinner
User font scaling✅ Scales automatically❌ Fixed, ignores prefsrem
Accessibility (WCAG)✅ Passes 1.4.4❌ Can fail 1.4.4rem
Predictability✅ Always root-relative✅ Always fixedTie
Mental model🟡 Requires formula✅ Intuitive pixelspx
Design system scaling✅ One root change = all❌ Must update each valuerem
Fluid typography✅ Works with clamp()🟡 Limited with clamp()rem
Borders & shadows🟡 Slightly awkward✅ Perfect fitpx
Browser support✅ Universal (IE9+)✅ UniversalTie
💡
The Practical Rule

Use rem for everything that relates to text and spacing: font-size, line-height, padding, margin, gap, width, height, border-radius. Use px for properties that should never scale with text: border widths (1px, 2px), box-shadow blur/spread, outline widths, and icon strokes. This hybrid approach gives you the accessibility benefits of rem where they matter, and the pixel precision where you need it.

6. Why rem Is Essential for Accessibility (WCAG 2.2)

This is the most important reason to switch from px to rem — and the one most developers overlook until they face an accessibility audit. WCAG 2.2 Success Criterion 1.4.4 (Resize Text) requires that text can be resized up to 200% without loss of content or functionality, except for captions and images of text.

When users set a larger default font size in their browser (a common accessibility accommodation for low vision, dyslexia, and age-related visual changes), font sizes set in px completely ignore this preference. They stay fixed at exactly the size you specified. Sizes set in rem scale proportionally with the user's preference.

Real Impact: 1 in 4 Adults Has a Disability

According to the CDC, 26% of adults in the United States have some form of disability. Visual impairments affect 2.2 billion people globally (WHO). Many of these users rely on browser zoom or enlarged default font sizes to read web content. A site built with px font sizes can be functionally inaccessible to this population — and a liability in jurisdictions where WCAG compliance is legally required (EU Accessibility Act, ADA in the US, Equality Act in the UK).

How Browser Font Size Preferences Work

When a user sets their browser default font size to 20px (instead of 16px):

CSS ValueUser sets 16px defaultUser sets 20px defaultScales?
font-size: 16px16px rendered16px renderedNo — ignored
font-size: 1rem16px rendered20px renderedYes — scales
font-size: 1.5rem24px rendered30px renderedYes — scales
font-size: 2rem32px rendered40px renderedYes — scales

7. How to Use rem in CSS — Practical Guide

Here is a complete, production-ready example of how to convert a typical CSS stylesheet from px to rem correctly:

CSS — Before (px only)
/* ❌ Before — all pixel values, not accessible */
body {
  font-size: 16px;
  line-height: 24px;
}

h1 { font-size: 48px; margin-bottom: 24px; }
h2 { font-size: 32px; margin-bottom: 16px; }
h3 { font-size: 24px; }
p  { font-size: 16px; margin-bottom: 16px; }

.card {
  padding: 24px;
  border-radius: 12px;
  margin-bottom: 32px;
}
CSS — After (rem for scale, px for details)
/* ✅ After — rem for typography/spacing, px for fine details */
html {
  font-size: 100%; /* Respects browser default (usually 16px) */
}

body {
  font-size: 1rem;     /* 16px — scales with user preferences */
  line-height: 1.5rem;  /* 24px */
}

h1 { font-size: 3rem;    /* 48px */  margin-bottom: 1.5rem; }
h2 { font-size: 2rem;    /* 32px */  margin-bottom: 1rem; }
h3 { font-size: 1.5rem;  /* 24px */ }
p  { font-size: 1rem;    /* 16px */  margin-bottom: 1rem; }

.card {
  padding: 1.5rem;      /* 24px — scales */
  border-radius: 12px;  /* px OK — visual detail */
  border: 1px solid #ccc; /* px OK — border precision */
  margin-bottom: 2rem;  /* 32px — scales */
}

8. The 62.5% Root Font Size Trick

One of the most popular techniques to make px-to-rem math effortless is setting the root font size to 62.5%. This makes 1rem = 10px instead of 16px, so the mental arithmetic is trivial — 24px becomes 2.4rem, 14px becomes 1.4rem.

CSS — 62.5% Root Trick
/* Set root to 10px via percentage (preserves user preferences) */
html {
  font-size: 62.5%; /* 62.5% of 16px = 10px */
}

/* Now 1rem = 10px — easy mental math! */
body  { font-size: 1.6rem; }  /* 16px */
h1    { font-size: 4.8rem; }  /* 48px */
h2    { font-size: 3.2rem; }  /* 32px */
p     { font-size: 1.6rem; }  /* 16px */
small { font-size: 1.2rem; }  /* 12px */
⚠️
62.5% Trick Caveat — Don't Forget body font-size

If you use the 62.5% trick, you must explicitly set body font-size: 1.6rem (or your preferred base size) — otherwise body text defaults to 10px, which is far too small. Also: never use html { font-size: 10px } — that overrides user preferences and defeats the accessibility purpose entirely. The 62.5% percentage approach preserves preference scaling while making the math easy.

9. px to rem in Tailwind CSS

Tailwind CSS uses a 4px spacing scale internally and expresses all values in rem in the compiled CSS. You don't need to manually convert px to rem when using Tailwind utilities — but understanding the mapping helps you choose the right classes. The most searched variant — px to rem converter tailwind — is answered simply: Tailwind already uses rem, and the table below shows every equivalent.

Tailwind Classrem Valuepx EquivalentUse Case
text-xs0.75rem12pxLabels, captions
text-sm0.875rem14pxSecondary text, small UI
text-base1rem16pxBody text (default)
text-lg1.125rem18pxSlightly larger body
text-xl1.25rem20pxCard titles, nav
text-2xl1.5rem24pxSection headings
text-3xl1.875rem30pxH2 alternatives
text-4xl2.25rem36pxH1 on mobile
text-5xl3rem48pxH1 on desktop
text-6xl3.75rem60pxHero headings
p-41rem16pxStandard padding
p-61.5rem24pxCard padding
p-82rem32pxSection padding

For custom values not in Tailwind's scale, use arbitrary value syntax:

HTML — Tailwind Arbitrary Values
<!-- Custom rem value using arbitrary syntax -->
<h1 class="text-[2.8rem] leading-[3.2rem]">Hero Title</h1>

<!-- Custom spacing -->
<div class="p-[1.3rem] mb-[2.5rem]">...</div>

<!-- Custom font size with line-height -->
<p class="text-[1.1rem] leading-[1.75rem]">Body text</p>

10. px to rem in Bootstrap

Bootstrap 5 made a complete shift to rem units for its typography system. The framework sets its root font size at 16px and uses rem throughout, making it fully compatible with user browser preferences. Developers frequently search for bootstrap px to rem conversions and css px to rem mapping tables — both are covered below.

Bootstrap ClassrempxApplied To
.fs-12.5rem40pxLargest heading
.fs-22rem32pxH2 equivalent
.fs-31.75rem28pxH3 equivalent
.fs-41.5rem24pxH4 equivalent
.fs-51.25rem20pxH5 equivalent
.fs-61rem16pxBody / H6
.small0.875rem14pxHelper text
.p-31rem16pxStandard padding
.p-41.5rem24pxCard padding
.p-53rem48pxSection padding

11. CSS clamp() with rem and vw — Fluid Typography

The most advanced use of rem is combining it with CSS clamp() and viewport units (vw) to create fluid typography that scales smoothly between a minimum and maximum size without any breakpoints. Tools like a fluid typography calculator or css clamp calculator help you generate the right values — but understanding the math lets you write it yourself. The css unit px to rem calculator at Vicspot gives you the rem values to plug directly into clamp().

CSS — Fluid Typography with clamp() + rem
/* Fluid font size: min 1rem (16px), max 3rem (48px) */
h1 {
  font-size: clamp(1rem, 4vw + 1rem, 3rem);
}

/* Fluid body text: min 1rem, max 1.25rem */
body {
  font-size: clamp(1rem, 1.5vw + 0.5rem, 1.25rem);
}

/* Fluid padding: min 1rem, max 3rem */
.section {
  padding: clamp(1rem, 5vw, 3rem);
}

/* Complete fluid type scale */
:root {
  --text-sm:   clamp(0.75rem,  1vw + 0.5rem,  0.875rem);
  --text-base: clamp(1rem,     1.5vw + 0.5rem, 1.125rem);
  --text-lg:   clamp(1.125rem, 2vw + 0.5rem,  1.5rem);
  --text-xl:   clamp(1.5rem,   3vw + 0.5rem,  2.5rem);
  --text-2xl:  clamp(2rem,     4vw + 1rem,    3.5rem);
}
🚀
Why clamp() + rem is the Future of CSS Typography

clamp() with rem values gives you: fluid scaling between viewport sizes (no breakpoints needed), accessibility-safe scaling (rem respects user preferences), and a predictable minimum and maximum so text never gets too small or too large. This is the approach used by major design systems including Material Design 3, Carbon Design System, and Atlassian Design System.

📐
Convert Any px Value to rem Instantly

Vicspot's free px ↔ rem calculator handles any base font size. Enter px → get rem. Enter rem → get px. No signup, works offline.

Open px↔rem Tool →