PX to REM Converter: rem, em, pt and Every CSS Length Unit
By FindMySum · Last reviewed
This px to rem converter turns pixel sizes into rem units at whatever root font size your site uses, and converts between every common CSS length: em, percent, points, picas, inches, centimetres, millimetres, Q, vw and vh. It also lists a table of common sizes, works out line height in pixels and turns design-tool letter spacing into CSS. An advanced option switches from CSS reference pixels to device pixels at a DPI, for print and design files.
Worked example: 24px
The converter opens with 24px and the browser default root font size of 16px.
- rem. 24 ÷ 16 = 1.5rem.
- Points. CSS fixes one inch at 96px and one point at 1/72 inch, so 24px × 72 ÷ 96 = 18pt.
- Physical size. 24 ÷ 96 = 0.25 inch, which is 0.635 cm or 6.35 mm.
- Line height. With line-height: 1.5, a 24px heading's lines are 36px apart.
If the site sets html { font-size: 62.5% }, the root is 10px and the same 24px is 2.4rem.
rem, em and percent
Font-relative units make text and spacing scale together.
- rem (root em) is the font size of the html element. Browsers default it to 16px, and readers can change that in their settings. Because every rem refers to the same root, rem values don't compound, which makes them the usual choice for a design system's type scale and spacing.
- em is the font size of the element itself; for the font-size property it is the parent's font size. A 1.25em heading inside a 20px container is 25px. Nesting em sizes multiplies them, which is useful for components that should scale with their surroundings and surprising when it is accidental.
- % for font-size works like em times 100: 150% is 1.5em.
Absolute units: the CSS inch
CSS defines its absolute units from a fixed ratio: 1in = 2.54cm = 96px = 72pt = 6pc. The px in this list is the reference pixel, an angle of view chosen so that text is readable at arm's length, not a physical dot on the screen. A phone with a device pixel ratio of 3 paints every CSS pixel with nine hardware pixels. So on screens a CSS inch is rarely an exact physical inch, but in print, where browsers lay out at the real size of the paper, it is.
Points and picas come from printing: a point is 1/72 inch (the PostScript point adopted by desktop publishing) and a pica is 12 points. Q, a quarter-millimetre, is the Japanese typesetting unit.
Device pixels for print and design files
Image editors and print workflows count real pixels at a resolution in dots or pixels per inch. At 72 pixels per inch, the old Mac screen resolution that desktop publishing grew up with, one point is one pixel. At 300 pixels per inch, the common target for print, one inch is 300 pixels and 12pt type is 50 pixels tall. Choose "device pixels" and enter the resolution to convert at that density instead of the CSS 96.
Viewport units
1vw is 1% of the viewport width and 1vh 1% of its height. They are handy for full-screen sections and fluid type, but text sized only in vw doesn't respond to the reader's zoom or font settings, so fluid type is usually written with clamp() combining rem and vw. Enter your viewport size in the advanced options to see the pixel value.
Accessibility and the root font size
The Web Content Accessibility Guidelines require that text can be resized up to 200% without losing content or function. Font sizes in rem or em honour a reader's default font size; font sizes in px don't respond to that setting, although browser zoom still works. Using rem for type, and checking layouts at larger root sizes, is a simple way to meet the requirement.
Letter spacing from design tools
Design tools express tracking relative to the font size. Adobe applications use thousandths of an em, so tracking of 50 is 0.05em, and Figma's percentage letter spacing is the same idea (5% is 0.05em). Writing letter-spacing in em in CSS keeps it proportional when the font size changes; the converter also shows the pixel value for the current size.
More questions
Should I use rem for everything, including padding and borders?
Many teams use rem for font sizes and spacing so the whole layout scales with the reader's font setting, and keep px for hairline borders and shadows, which should stay thin. Media queries in em or rem also respond to the font setting. There's no single rule; consistency within a project matters most.
Why do my rem values look wrong inside a component library?
rem always follows the html element's font size. If your site changes it (the 62.5% trick, or a responsive root size), any library that assumed 16px will scale with it. Check the computed font size of the html element in your browser's developer tools and enter it as the root font size here.
What is a pica?
A pica is 12 points, or one sixth of an inch, the unit typographers and newspaper designers use for column widths and line lengths. In CSS, 1pc = 16px. A 30-pica column is 5 inches wide.
What is the Q unit?
Q is a quarter of a millimetre (0.25 mm), taken from Japanese typesetting, where type sizes are measured in Q. CSS added it so print style sheets can use it. 10mm = 40Q, and 1Q is about 0.945px.
Are pt and px the same in Photoshop or Illustrator?
In a document set to 72 pixels per inch they are: one point equals one pixel. That is why many design tools treat them as interchangeable. At 300 pixels per inch for print, one point is about 4.17 pixels. Choose device pixels and enter your document's resolution to convert.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.