Skip to content

PX to REM converter

Type a pixel or rem value and get the other, plus the Tailwind CSS 4 class. At the default 16px root, rem = px ÷ 16: 24px is 1.5rem, which is p-6 in Tailwind. Below it, paste a stylesheet to convert every value at once.

REM
1.5rem
PX
24px
Tailwind spacing
p-6
Tailwind text size
text-2xl
CSS
padding: 1.5rem;

Spacing works for p-, m-, gap-, w-, h-, inset- and the rest: swap the prefix.

Preview at actual size24px · 1.5rem

The quick brown fox jumps over the lazy dog

024px wide
padding

Convert a whole stylesheet

Every px becomes rem (or back). Comments, url() and names like --gap-4px stay as they are.

9 values converted
.card {
  padding: 1.5rem 1.25rem;
  margin-bottom: 2rem;
  border: 1px solid #e4e4e7;
  border-radius: 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.5rem;
  gap: 0.75rem;
}

@media (min-width: 48rem) {
  .card { padding: 2.5rem; }
}

PX to REM table

The values people look up most, at the default 16px root font size, with the Tailwind CSS 4 class for each. For a whole type scale on Tailwind's names, use the font size generator.

PXREMTailwind spacingText size
1px0.0625remp-pxtext-[1px]
2px0.125remp-0.5text-[2px]
4px0.25remp-1text-[4px]
6px0.375remp-1.5text-[6px]
8px0.5remp-2text-[8px]
10px0.625remp-2.5text-[10px]
12px0.75remp-3text-xs
13px0.8125remp-3.25text-[13px]
14px0.875remp-3.5text-sm
15px0.9375remp-3.75text-[15px]
16px1remp-4text-base
18px1.125remp-4.5text-lg
20px1.25remp-5text-xl
22px1.375remp-5.5text-[22px]
24px1.5remp-6text-2xl
28px1.75remp-7text-[28px]
30px1.875remp-7.5text-3xl
32px2remp-8text-[32px]
36px2.25remp-9text-4xl
40px2.5remp-10text-[40px]
44px2.75remp-11text-[44px]
48px3remp-12text-5xl
56px3.5remp-14text-[56px]
60px3.75remp-15text-6xl
64px4remp-16text-[64px]
72px4.5remp-18text-7xl
80px5remp-20text-[80px]
96px6remp-24text-8xl
100px6.25remp-25text-[100px]
128px8remp-32text-9xl

A rem-based type and spacing scale, in finished blocks

12 of 147 free, no account. All of them in UI Pro.

  • Hero (hero-01)01

    Hero

    hero-01 · Free. Journey-planner hero: from/to card with leave-at tabs, a day-out photo card and four quick-task tiles.

    Open hero-01
  • Plain tiles (features-01)02

    Plain tiles

    features-01 · Free. Three open photo tiles with a step, a title and two lines each under a centred heading; no card chrome.

    Open features-01
  • 03

    All free blocks

    Every one with a live preview, filtered to the ones you can use for free first.

    See them all

Questions

How do I convert px to rem?

Divide the pixel value by the root font size. Browsers use 16px unless the page changes it, so 24px is 24 ÷ 16 = 1.5rem, 14px is 0.875rem and 1px is 0.0625rem. To go back, multiply: 2rem × 16 = 32px.

What is 1rem in px?

1rem is the font size of the html element: 16px by default. If your CSS sets html { font-size: 62.5% }, 1rem is 10px; set the root size above the converter to match your site.

Which Tailwind class is 24px?

p-6, m-6, gap-6, w-6 and the rest of the spacing utilities with 6: Tailwind 4 multiplies the number by --spacing, 0.25rem, so 6 × 0.25rem = 1.5rem = 24px. The rule is px ÷ 4 at the default root size. Tailwind 4 accepts any multiple of 0.25, so 13px is p-3.25; anything else becomes an arbitrary value like p-[13.5px].

Should I use rem or px?

Use rem for font sizes and most spacing: it follows the reader's browser font-size setting, which matters for accessibility. Keep px for hairlines (1px borders) and things that should not grow with text. That is why the stylesheet converter leaves 1px alone unless you tell it otherwise.

Does rem in a media query use my root font size?

No. rem in a media query always uses the browser's initial font size (16px by default), not the size you set on html. Tailwind 4 writes its breakpoints in rem for this reason: md is 48rem, which is 768px at the default size.

Is it free?

Yes. No sign-up, and nothing leaves your browser.

UI Pro

Build your next site from finished blocks

Every block, page template and website theme from €199, paid once, with every update and everything we add later. Not ready? The free blocks are open to everyone.

blocks
1401
page templates
55
website themes
29
The About page template from UI Pro, built from its blocks.

This card is a UI Pro block: Rooilijn (call-to-action-07).