CSS unit converter (px to rem, em, pt)

Convert px to rem, em, pt, picas, inches and mm using your root font size, parent font size and DPI. CSS fixes 1 in = 96 px = 72 pt.

Drafted with AI writing toolsUpdated Checked examples: 7

px
More options
px
DPI
CSS fixes 1 in = 96 px. Enter a screen or printer density (e.g. 300) to count physical pixels instead.
Try
Converted value
rem
Converted value: 1.5 rem
Significant figures: 10; Nearest, ties away from zero
As CSS
1.5rem
In pixels
24px

24px is 1.5rem with a 16 px root font and 96 pixels per inch.

Size in pixels next to the font sizes

24px24 px1 rem (root)16 px1 em (parent)16 px
24px in every unit Rows: 10
UnitValueDefinition
Pixels (px)24px1 px
Points (pt)18pt1 pt = 1/72 in
Picas (pc)1.5pc1 pc = 12 pt = 1/6 in
Inches (in)0.25in1 in = DPI px
Centimetres (cm)0.635cm1 cm = 1/2.54 in
Millimetres (mm)6.35mm1 mm = 1/25.4 in
Quarter-millimetres (Q)25.4Q1 Q = 0.25 mm
em (parent font size)1.5em1 em = parent font size
rem (root font size)1.5rem1 rem = root font size
Percent of parent font size (%)150%100% = parent font size
How it's calculated S
  1. Pixels in one px

    1 px=1 px1\,\text{px} = 1\ \text{px}

    1 px

  2. Value in pixels

    24×1=24 px24 \times 1 = 24\ \text{px}
  3. Divide by pixels in one rem

    2416=1.5 rem\frac{24}{16} = 1.5\ \text{rem}

    1 rem = root font size

About the CSS unit converter

CSS converts every length through pixels. The absolute units are fixed to each other: 1 in = 2.54 cm = 96 px = 72 pt = 6 pc, and 1 Q is a quarter of a millimetre. The font-relative units depend on the page: 1 rem is the root element's font size, and when you set font-size, 1 em (or 100%) is the parent's font size. The converter turns the value into pixels, then divides by the pixels in one target unit.

Front-end developers use it to turn a design's pixel sizes into rem, so text can follow the reader's browser font setting when the root font size respects that preference: with the default 16 px root, 24 px is 1.5 rem. Print designers use the pixels-per-inch field instead; at 300 DPI a 10 mm logo needs about 118 pixels.

A CSS inch need not be a measured screen inch. CSS defines 96 px per inch, and its reference pixel has a visual angle of about 0.0213°. Implementations can anchor absolute units either to physical measurements or to pixels; device mapping, viewing distance and print scaling affect whether a ruler matches.

In the formula, xₛ and xₜ are the source and target values; pₛ and pₜ are pixels per source and target unit. These factors use the font sizes and pixel density you enter.

How to convert px to rem

Divide the pixels by the root font size. At the usual browser default of 16 px, 24 px = 24 ÷ 16 = 1.5 rem. If a stylesheet sets html { font-size: 62.5% }, the root is 10 px and 24 px is 2.4 rem. Multiply by the root size to go back to px.

Common px to rem values

At a 16 px root:

  • 10 px = 0.625 rem
  • 12 px = 0.75 rem
  • 14 px = 0.875 rem
  • 16 px = 1 rem
  • 18 px = 1.125 rem
  • 20 px = 1.25 rem
  • 32 px = 2 rem
  • 48 px = 3 rem

The 16 px root is a common browser default, not a rule of the CSS specification, and readers can change their browser's default font size. A rem value follows that preference when the page's root font-size rule respects it; a fixed root size can override it. A fixed px value does not follow that preference.

em vs rem

rem always refers to the root element's font size. em refers to the parent's font size when used on font-size, and to the element's own font size on other properties such as padding.

A percentage font size works like em: 150% of a 20 px parent is 30 px. Percentages on other properties use other bases; a percentage width is a share of the containing block's width.

em compounds when nested, because each level inherits the last. A list at 1.2em inside another list at 1.2em has text 1.44 times the shared starting font size, while 1.2rem stays 19.2 px at a 16 px root however deep it sits.

How to convert px to pt, inches and mm

CSS fixes its absolute units to each other: 1 in = 96 px = 72 pt = 6 pc = 2.54 cm, and 1 Q is a quarter millimeter (W3C CSS Values and Units). From those:

  • px to pt: multiply by 0.75, so 16 px = 12 pt.
  • pt to px: multiply by 4/3, so 12 pt = 16 px and 11 pt ≈ 14.67 px.
  • pc to pt: 1 pc = 12 pt = 16 px.
  • mm to px: multiply by 96/25.4 ≈ 3.7795, so 10 mm ≈ 37.8 px.

A CSS inch is not a ruler inch on screen

The CSS reference pixel has a visual angle of about 0.0213°. Implementations can anchor absolute units to physical measurements or to pixels; a CSS inch therefore need not match a ruler inch on a screen.

Device pixel mapping and viewing distance affect the correspondence, so a 96 px box can measure less than an inch on a phone. The PPI calculator gives a display's real pixel density from its resolution and diagonal, which is what decides how large a CSS inch looks. Physical-unit anchoring and correctly scaled actual-size printing can match a ruler; calibration and output scaling still matter.

Pixels for print at 300 DPI

Print and image work count physical pixels, so use the output resolution instead of 96. At 300 DPI, 1 inch is 300 pixels and 10 mm is 10 ÷ 25.4 × 300 ≈ 118.11 pixels. The millimeters to inches converter handles the physical side on its own, and the length converter covers the other metric and imperial units. Browser CSS still uses 96 px per inch, whatever the screen.

CSS unit conversion examples

Each row states the context that changes the answer: the root size for rem, the parent size for em and %, and the pixels per inch for physical units.

ValueFromToContextConverted value
24pxremRoot 16 px1.5
24pxremRoot 20 px1.2
12ptpx96 pixels/in16
1pcpt96 pixels/in12
100%emParent 16 px1
10mmpx300 pixels/in118.110236

px or rem for font sizes?

Use rem when text should follow the reader's default font-size setting, and make sure the root rule respects that preference. Browser zoom enlarges px and rem alike. A font-size preference can also affect rem, em and percentage sizes when their root or parent context preserves it; a fixed font size can override that context.

WCAG 2.1 success criterion 1.4.4 asks that text can be resized to 200% without loss of content or functionality. Browser zoom can meet it with either unit; rem also follows the font-size preference when the root rule respects it.

Percent, DPI and negative values

  • The % unit means percent of the parent font size, as in a font-size declaration.
  • A pixels-per-inch value other than 96 makes px count physical pixels at that density, as for print.
  • Negative values convert with their sign, as for a negative margin.

Worked examples

24 px in rem

Value
24
From
Pixels (px)
To
rem (root font size)
Root font size (for rem)
16 px
Converted value
1.5 rem
As CSS
1.5rem
In pixels
24 px

Checked against: CSS Values 3 §6.1: 1rem = root font size (16 px browser default); 24 / 16 = 1.5

12 pt in px

Value
12
From
Points (pt)
To
Pixels (px)
Root font size (for rem)
16 px
Converted value
16 px
As CSS
16px

Checked against: CSS Values 3 §6.2: 1pt = 1/72 in, 1in = 96px; 12 × 96/72 = 16

1 inch in CSS pixels

Value
1
From
Inches (in)
To
Pixels (px)
Root font size (for rem)
16 px
Converted value
96 px

Checked against: CSS Values 3 §6.2: 1in = 96px

1.5 rem in px

Value
1.5
From
rem (root font size)
To
Pixels (px)
Root font size (for rem)
16 px
Converted value
24 px

Checked against: 1 rem = root font size (16 px); 1.5 × 16

Questions

How many pixels is 1 rem?

16 pixels by default. One rem equals the font size of the root html element, and the major browsers set that to 16 px unless the reader changes the default font size or the stylesheet sets html { font-size }. Setting html { font-size: 62.5% } makes 1 rem = 10 px. The W3C CSS Values and Units specification defines rem; the 16 px figure is the browser default, not part of the specification.

How do I convert px to pt?

Multiply pixels by 0.75; to go from points to pixels, multiply by 4/3 (about 1.333). Both factors follow from the W3C CSS rule 1 in = 96 px = 72 pt, so 1 px = 72/96 pt. Body text at 16 px is 12 pt, and 11 pt text from a word processor is about 14.67 px.

What is the difference between em and rem?

rem always refers to the root element's font size; em refers to the current element's font size, or to the parent's when used on font-size itself. So em compounds when nested: a list set to 1.2em inside another list set to 1.2em has text 1.44 times the original shared base font size, while 1.2rem stays at 19.2 px with a 16 px root however deep it sits.

Should I use px or rem for font sizes?

Use rem when text should follow the reader’s browser font-size setting, and let the root font size respect that preference. Page zoom enlarges px and rem alike; rem, em and percentage sizes can follow font-size preferences through their root or parent context. WCAG 2.1 success criterion 1.4.4 (level AA) requires text that can be resized to 200% without loss of content or function. Browser zoom can meet that requirement with px; rem can additionally honour the font-size preference when its root context permits it.

Is a CSS inch the same as a real inch?

A CSS inch need not match a measured screen inch. CSS defines 1 in as exactly 96 px; its W3C reference pixel is one pixel on a 96 DPI screen viewed from 28 in away, a visual angle of about 0.0213°. Device mapping and viewing distance vary, so a 96 px box can measure less than a physical inch on a phone. In actual-size print, the CSS relation 1 in = 25.4 mm can match a ruler; print scaling and calibration still affect the physical output.

About this calculator

xt=xs×pspt1 in=96 px=72 pt=2.54 cm\begin{gathered} x_{t} = x_{s} \times \frac{p_{s}}{p_{t}} \\ 1\,\text{in} = 96\,\text{px} = 72\,\text{pt} = 2.54\,\text{cm} \end{gathered}

Sources

  1. W3C — CSS Values and Units Module Level 3, §6.2 absolute lengths and §6.1 font-relative lengths

Checked against references

This calculator includes 7 worked examples with independently sourced answers. They run in the test suite, and you can run them here too.

Put this calculator on your site

Paste this where you want the calculator to appear. It is free to use, it stays in step with corrections made here, and the credit line below it links back so your readers can find the full version.

Height
Preview the embed

Keep the credit line. It is the only condition, and it is what keeps these calculators free.