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.
| Unit | Type | Relative To | Best Used For |
|---|---|---|---|
| px | Absolute | Device pixels (fixed) | Borders, shadows, icons, pixel-perfect details |
| rem | Relative | Root element font size (html) | Font sizes, spacing, layout — anything scalable |
| em | Relative | Parent element font size | Component-level spacing tied to local font size |
| % | Relative | Parent element dimension | Widths, heights, fluid layouts |
| vw / vh | Relative | Viewport width / height | Full-screen sections, fluid hero layouts |
| ch | Relative | Width of the "0" character | Prose containers, line length control |
| clamp() | Function | Min, preferred, max values | Fluid 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.
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.
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
| Calculation | Result | Common Use Case |
|---|---|---|
| 16px ÷ 16 | 1rem | Base body font size — 16px to rem = 1rem |
| 14px ÷ 16 | 0.875rem | Small text, captions |
| 18px ÷ 16 | 1.125rem | Slightly larger body text |
| 24px ÷ 16 | 1.5rem | H3 headings — 24px to rem = 1.5rem |
| 32px ÷ 16 | 2rem | H2 headings |
| 48px ÷ 16 | 3rem | Hero headings, H1 |
| 64px ÷ 16 | 4rem | Display / large hero text |
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.
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 Value | rem Value | Common Use |
|---|---|---|
| 1px | 0.0625rem | Borders, dividers |
| 2px | 0.125rem | Thin borders |
| 4px | 0.25rem | Micro spacing, border-radius |
| 6px | 0.375rem | Small gaps |
| 8px | 0.5rem | Padding XS, gap-2 in Tailwind |
| 10px | 0.625rem | Small labels |
| 12px | 0.75rem | Caption text, text-xs |
| 14px | 0.875rem | Small body text, text-sm |
| 16px | 1rem | Base font size, text-base |
| 18px | 1.125rem | Large body text, text-lg |
| 20px | 1.25rem | text-xl, nav font size |
| 22px | 1.375rem | Medium heading |
| 24px | 1.5rem | H3, text-2xl, card title |
| 28px | 1.75rem | text-3xl, subheading |
| 32px | 2rem | H2, text-4xl |
| 36px | 2.25rem | text-4xl alt |
| 40px | 2.5rem | Section heading, text-5xl |
| 44px | 2.75rem | Large heading |
| 48px | 3rem | H1 desktop, text-5xl |
| 56px | 3.5rem | Hero subheading |
| 64px | 4rem | Hero title, display text |
| 72px | 4.5rem | Large display |
| 80px | 5rem | Extra large display |
| 96px | 6rem | Massive 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:
- 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
- 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
| Property | rem | px | Winner |
|---|---|---|---|
| User font scaling | ✅ Scales automatically | ❌ Fixed, ignores prefs | rem |
| Accessibility (WCAG) | ✅ Passes 1.4.4 | ❌ Can fail 1.4.4 | rem |
| Predictability | ✅ Always root-relative | ✅ Always fixed | Tie |
| Mental model | 🟡 Requires formula | ✅ Intuitive pixels | px |
| Design system scaling | ✅ One root change = all | ❌ Must update each value | rem |
| Fluid typography | ✅ Works with clamp() | 🟡 Limited with clamp() | rem |
| Borders & shadows | 🟡 Slightly awkward | ✅ Perfect fit | px |
| Browser support | ✅ Universal (IE9+) | ✅ Universal | Tie |
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.
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 Value | User sets 16px default | User sets 20px default | Scales? |
|---|---|---|---|
| font-size: 16px | 16px rendered | 16px rendered | No — ignored |
| font-size: 1rem | 16px rendered | 20px rendered | Yes — scales |
| font-size: 1.5rem | 24px rendered | 30px rendered | Yes — scales |
| font-size: 2rem | 32px rendered | 40px rendered | Yes — 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:
/* ❌ 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;
}
/* ✅ 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.
/* 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 */
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 Class | rem Value | px Equivalent | Use Case |
|---|---|---|---|
| text-xs | 0.75rem | 12px | Labels, captions |
| text-sm | 0.875rem | 14px | Secondary text, small UI |
| text-base | 1rem | 16px | Body text (default) |
| text-lg | 1.125rem | 18px | Slightly larger body |
| text-xl | 1.25rem | 20px | Card titles, nav |
| text-2xl | 1.5rem | 24px | Section headings |
| text-3xl | 1.875rem | 30px | H2 alternatives |
| text-4xl | 2.25rem | 36px | H1 on mobile |
| text-5xl | 3rem | 48px | H1 on desktop |
| text-6xl | 3.75rem | 60px | Hero headings |
| p-4 | 1rem | 16px | Standard padding |
| p-6 | 1.5rem | 24px | Card padding |
| p-8 | 2rem | 32px | Section padding |
For custom values not in Tailwind's scale, use arbitrary value syntax:
<!-- 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 Class | rem | px | Applied To |
|---|---|---|---|
| .fs-1 | 2.5rem | 40px | Largest heading |
| .fs-2 | 2rem | 32px | H2 equivalent |
| .fs-3 | 1.75rem | 28px | H3 equivalent |
| .fs-4 | 1.5rem | 24px | H4 equivalent |
| .fs-5 | 1.25rem | 20px | H5 equivalent |
| .fs-6 | 1rem | 16px | Body / H6 |
| .small | 0.875rem | 14px | Helper text |
| .p-3 | 1rem | 16px | Standard padding |
| .p-4 | 1.5rem | 24px | Card padding |
| .p-5 | 3rem | 48px | Section 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().
/* 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);
}
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.
Vicspot's free px ↔ rem calculator handles any base font size. Enter px → get rem. Enter rem → get px. No signup, works offline.
💬 Questions & Comments