CSS Unit Converter

Convert between px, rem, em and pt. Set the root font size, see all four values for the same length, and use the reference table for common sizes. Everything is computed locally.

The browser default is 16px. rem is relative to the root element, while em is relative to the current element font size.

Converted values
px -
rem -
em -
pt -

Common sizes

Calculated with the root font size above; pt is based on 1px = 0.75pt (96 DPI).

px rem em pt

About CSS units

px is an absolute unit, rem is relative to the root font size and em is relative to the current element font size. That is why 16px equals 1rem only when the root is 16px. If a user has set a larger default font, the same rem value renders larger, which is exactly why rem is preferred for accessible layouts.

pt comes from print typography: 1 inch is 72pt and a CSS inch is 96px, so 1px equals 0.75pt. This converter keeps that relationship while using your configured root size for rem and em. Everything runs locally and updates as you type.

The units in this converter are only part of the picture, and the ones left out fail in ways that look like conversion errors. A percentage in CSS is not a unit with a fixed size: for width it resolves against the containing block width, but for margin and padding, vertical values also resolve against the width, so 10% top padding on a wide element produces a surprising vertical gap. Viewport units follow the same pattern, where 1vw is one percent of the viewport width and 1vh one percent of its height; on mobile browsers the visible height changes as toolbars appear, which is why the newer svh, lvh and dvh variants exist. For text, ch measures the width of a zero and ex roughly the x-height, both tied to the current font, so they change when the typeface changes.

Accessibility is decided by which unit you choose, not by the numbers themselves. A layout written entirely in px ignores the browser setting that raises the default font size, while rem follows it, which is what the WCAG guidance on resizing text expects. Page zoom enlarges everything and is not a substitute, because it also scales images and the viewport, whereas a user who changes only the default font size expects text to grow inside the same layout. The well-known 62.5% trick sets the root to 10px for mental arithmetic, but it inherits the user setting, so a person with a 20px default gets 12.5px; the code stays proportional, yet a fixed pixel override on html breaks that chain.

One CSS pixel is not one device pixel. On a display with a device pixel ratio of 2, a 1px border covers two physical pixels, and on a 3x phone it covers three, which is why hairlines look heavier on some screens and why bitmap images need a 2x source to stay sharp. Print is a separate model again: CSS defines one inch as 96px, so pt relates to px through a fixed 0.75 factor, while a real printer may render that inch with different fidelity. A PDF exported from a browser keeps the CSS relationship, but a document opened in a word processor may interpret pt with the typographic definition, so a 12pt heading can measure slightly differently in the two places.

How to convert CSS units

  1. Enter the value you want to convert and choose its unit.
  2. Set the root font size: 16px is the browser default, but a project may use 10px or 62.5%.
  3. Read all four values: px, rem, em and pt.
  4. Use the reference table for common sizes, and copy the value you need.
  5. Check the computed value rather than trusting the source: browser developer tools show the used px value next to each declaration, which immediately reveals whether a rem depends on a root size you did not expect.
  6. Switch tools when the value has to be fluid: for clamp-based typography, container queries or percentage layouts, the answer depends on the viewport or the parent, so a fixed four-unit conversion cannot express it.

Frequently asked questions

Should I use rem or em?

Use rem for global sizing such as spacing, typography and layout, because it follows the root font size and ignores nesting. Use em when a component should scale with its own font size, for example padding inside a button.

Why is 1rem not always 16px?

Because rem is whatever the root font size is. The browser default is 16px, but a user can change it and a site can set html { font-size: 62.5% } to make 1rem equal 10px. That flexibility is the accessibility benefit.

Does pt depend on the screen?

No. In CSS, pt has a fixed relationship to px (1px = 0.75pt), independent of the physical screen. It is mainly useful when matching print styles.

Are fractional results rounded?

They are shown with up to about six significant digits, which is enough for CSS. Browsers accept fractional px, rem, em and pt values, so keep the precision you need rather than rounding to whole numbers.

Is 1px the same as one device pixel?

No. A CSS pixel is a logical unit that is scaled by the device pixel ratio, so on a 2x display one CSS pixel covers four physical pixels in a 2 by 2 block, and a 1px border looks about twice as thick as on a 1x screen. That is why screenshots for retina assets are exported at twice the CSS size.

Why is percentage padding calculated from the width?

The CSS specification resolves percentage margins and padding against the inline size of the containing block for all four sides, so vertical padding follows the width, not the height. A common workaround is the padding-top ratio trick for fixed-aspect boxes, now largely replaced by the aspect-ratio property.

Should I set the root font size to 62.5%?

It makes 1rem equal 10px when the browser default is 16px, which simplifies arithmetic, and because it is a percentage it still follows the user default. The cost is that every value in the stylesheet must be multiplied by ten, and any later rule that sets html to a fixed px size cancels the accessibility benefit entirely.