This px to rem converter turns any pixel value into the equivalent rem (and em) unit instantly, with a live bidirectional calculator: type in pixels and see rem, or type in rem and see pixels. Change the base font size and the reference table below updates in real time. The default base is 16px — the browser standard — but you can enter 10px, 14px, or any custom root value your design system uses. Click any cell in the reference grid to copy its value. A one-click CSS variables export generates a ready-to-paste :root block with a standard typography scale.
rem is always relative to the root element's font-size, making it predictable across your document. em is relative to the parent element's font-size, so nested em values compound. Use rem for typography scales, spacing, and breakpoints; use em for component-local sizing (padding, gap) that should scale with the component's own text.
"Should I use px, em, or rem?" is a question every CSS author hits in their first month and still hits ten years later for new edge cases. The answer is not "rem for everything" — different units exist because different jobs demand different scaling behaviour. This guide is the working reference: how each unit is defined, the formula for converting between them, the accessibility argument for rem-based typography (it is a real WCAG requirement, not an opinion), and the modern viewport-relative units that ship in every evergreen browser.
| Unit | Defined as | Best for |
|---|---|---|
px | 1/96 of an inch (CSS reference pixel — not the device pixel) | Hairline borders, shadow offsets, exact-pixel icons. |
em | Current element's computed font-size | Padding, gap, border-radius that should scale with local text. |
rem | Root element's font-size (typically 16 px) | Typography, spacing scale, breakpoints. |
% | Parent dimension (depends on property) | Fluid layouts, image sizing. |
vw / vh | 1% of viewport width / height | Hero sections, full-bleed components. |
svw / svh / lvw / lvh / dvw / dvh | Small / large / dynamic viewport (mobile-aware, 2022+) | Mobile UI that has to dodge the URL bar. |
ch | Width of "0" character in current font | Reading-width constraints (max-width: 65ch). |
ex | x-height of current font | Vertical alignment of inline icons. |
cap | Capital letter height | Cap-aligned drop caps and badges. |
fr | Fraction of available space (Grid only) | Grid track sizing. |
Given a default 16 px root and 16 px parent:
rem = px / root_font_sizeem = px / parent_font_sizepx = rem × root_font_sizepx = em × parent_font_sizeWorked examples for the standard 16 px root:
| px | rem (16 px root) | rem (10 px root) | Use |
|---|---|---|---|
| 12 px | 0.75 rem | 1.2 rem | Caption / fine print |
| 14 px | 0.875 rem | 1.4 rem | Secondary text |
| 16 px | 1 rem | 1.6 rem | Body text — never go below in 2026 |
| 18 px | 1.125 rem | 1.8 rem | Lead paragraph |
| 24 px | 1.5 rem | 2.4 rem | H4 / subhead |
| 32 px | 2 rem | 3.2 rem | H2 / section heading |
| 48 px | 3 rem | 4.8 rem | H1 / hero heading |
WCAG 2.1 Success Criterion 1.4.4 Resize Text requires that text can be scaled up to 200% without loss of content or functionality. Browsers implement this through two mechanisms:
Roughly 4% of users override their default browser font size. A site authored in pure pixels ignores them entirely — text stays the same physical size when the user has explicitly told the browser they need it larger. This is the single strongest argument for rem-based typography in production code.
Many design systems use this idiom:
html {
font-size: 62.5%; /* 10 px on a default 16 px root */
}
body {
font-size: 1.6rem; /* 16 px — restore default body size */
}
Now the rem math is trivial: 1 rem = 10 px, 1.6 rem = 16 px, 2 rem = 20 px. The percentage form is critical — using html { font-size: 10px } instead breaks user font-size preferences. With 62.5%, the result still scales when a user bumps their default to 20 px (yielding a 12.5 px effective root rather than ignoring the preference entirely).
Em is the right choice when you want a value to scale with its local context, not the document root:
padding: .5em 1em grows when you bump the button font size to make a "large" variant.border-radius: .5em stays proportional whether the card is heading-sized or body-sized.height: 1em; width: 1em tracks the text exactly.margin-bottom: 1em = "one line of space below".The trap with em: nesting compounds. A 1.5 em heading inside a 1.2 em parent inside a 1.1 em grandparent computes to 1.5 × 1.2 × 1.1 = 1.98 em — almost double. Use rem when you want to opt out of this compounding.
Mobile browsers have a long-running headache: the URL bar appears and disappears as the user scrolls. The original 100vh meant "full viewport height", but on mobile that height changes by ~50 px during scroll, causing layout thrash. The 2022+ solution shipped three new variants:
svh — small viewport height (URL bar visible). Always the smaller value.lvh — large viewport height (URL bar hidden). Always the larger value.dvh — dynamic viewport height. Updates as the URL bar moves. Use this for "fill the screen" containers.The corresponding width variants (svw, lvw, dvw) follow the same pattern. As of 2026 these are supported in every evergreen browser; for mobile-first hero sections, min-height: 100dvh is the modern replacement for min-height: 100vh.
CSS Container Queries (2023) introduced a new family of units that resolve against the nearest container, not the viewport:
cqw / cqh — 1% of container width / height.cqi / cqb — 1% of container inline / block size (writing-direction-aware).cqmin / cqmax — smaller / larger of cqi and cqb.Use case: a card component where font-size scales with the card's width, regardless of where the card lands. font-size: clamp(1rem, 4cqi, 1.5rem) caps the responsive growth.
html { font-size: 10px } instead of 62.5%. Breaks the user's accessibility font-size preference.min-width resolution. Modern browsers do the right thing; older Safari versions had bugs. Em-based breakpoints are still safer.clamp() with both rem and vw bounds.height: 100vh on mobile heroes. The URL bar makes that taller than the screen. Use 100dvh.min-width media queries match in computed pixels. If you write @media (min-width: 48rem) and a user has a 20 px root, the breakpoint hits at 960 px, not 768 px — desired behaviour, but surprising.| Stack | How to handle conversion |
|---|---|
| Tailwind CSS | Default spacing scale is rem-based; w-4 = 1 rem. |
| PostCSS | postcss-pxtorem rewrites all px to rem at build time. |
| SCSS / Less | @function px-to-rem($px) { @return ($px / 16) * 1rem; } |
| Figma → code | Locofy, Builder.io, and StyleX exporters emit rem. |
| shadcn/ui, Radix, Material UI | Default to rem-based tokens. |
Search results for "px to rem converter", "pixel to rem", "rem calculator" return many tools but most are bare calculators. Three things separate the good from the noise: bidirectional input (rem ↔ px both directions), custom base font size (10px / 14px design systems aren't 16px), and CSS variables export for design-token workflows. Here's how the most-used px-to-rem tools compare in 2026:
| Tool | Bidirectional | Custom base | Reference table | CSS vars export | Cost |
|---|---|---|---|---|---|
| FreeDevTool PX to REM | Yes | Yes (any base) | Yes (live) | Yes (--text-* / --space-*) | Free |
| nekocalc.com/px-to-rem-converter | Yes | Yes | Limited | No | Free, ad-funded |
| pxtoem.com | Yes | Limited | Yes | No | Free |
PostCSS postcss-pxtorem | Build-time | Yes | N/A | Inline replacement | Free, OSS |
| Tailwind CSS spacing scale | Pre-defined rem-based | Yes (config) | Yes (docs) | Built-in tokens | Free |
Five units cover 95% of CSS sizing. px: absolute pixel — does NOT scale with user zoom or root font-size; use only for borders, hairlines, shadow offsets. rem: relative to ROOT font size (default 16px); scales with user accessibility zoom; use for everything sizable (text, spacing, breakpoints). em: relative to PARENT font size; nests/compounds (which can surprise); use for component-local scale (button padding scaling with button text size). %: relative to parent dimension; use for fluid widths/heights. vw/vh: relative to viewport; use for full-screen layouts. ch: relative to "0" character width; use for code line lengths and prose max-width (45-75ch is the readability sweet spot).
Default: 1rem = 16px (the browser's html { font-size } default). To use a custom base: enter the new base in the "Base font size" field — the entire reference table and bidirectional calculator update instantly. Two common non-default bases: 10px base ("html { font-size: 62.5% }" or "10px") makes the math trivial — 1rem = 10px, 1.6rem = 16px. Common in design systems where designers think in 10s. 14px base for compact dashboards/admin UIs where 16px feels too large. Critical accessibility note: overriding the root font-size to 10px breaks user-set browser font-size preferences (a user who set their default to 20px for accessibility now gets 12.5px effective base). The accessible alternative: keep 16px root and use 0.625rem as your "10px equivalent" via design-token math.
:root { --text-sm: 0.875rem; --text-base: 1rem; --space-2: 0.5rem; ... } block — saves the manual scale-table-to-CSS conversion.Pair the PX to REM converter with the Hex to RGB Converter for color tokens, the WCAG Contrast Checker for accessibility-pass color pairs, the CSS Gradient Generator for gradient tokens, and the Encoding Tools hub for the broader CSS toolkit.
rem = pixels / root-font-size. By default browsers render the root element (html) at 16px, so 16px equals 1rem, 24px equals 1.5rem, and 32px equals 2rem. If a design system sets html { font-size: 10px }, the math becomes simpler — 10px equals 1rem and each 10px step is 1rem — but that approach can break user accessibility settings, so most teams stick with the 16px default and do conversion in their build tooling or with a tool like this.html) font-size — consistent across the entire document. em is relative to the current element's parent font-size, so nested em values compound: an em inside an em-sized container gets multiplied. Use rem for predictable spacing, typography scales, and media query breakpoints. Use em for component-local sizing where you want a child element (an icon, padding, border-radius) to scale naturally with its parent's font-size.postcss-pxtorem, shipped CSS respects user zoom and accessibility settings.html { font-size: 62.5% } sets rem to 10px while still respecting user zoom.All tools run in your browser, no signup required, nothing sent to a server.