CSS UNITS

CSS unit converter, px rem em in a flash.

Convert instantly between px, rem, em, pt and %, set root size and viewport width, and get a reference table. Handy for frontend slicing and responsive layout. Runs locally.

rem
1.0000
em
1.0000
pt
12.00
% (vw)
1.111

Reference table (root 16px)

8px = 0.500rem
10px = 0.625rem
12px = 0.750rem
14px = 0.875rem
16px = 1.000rem
18px = 1.125rem
20px = 1.250rem
24px = 1.500rem
32px = 2.000rem
40px = 2.500rem
48px = 3.000rem

How are units converted?

rem is relative to the root size (default 16px), em to the current size (estimated from root here), pt is a print point (1px = 0.75pt), and % in width is relative to the viewport (1vw = viewport/100). Change any value above and results update live.

FAQ

What is the real difference between rem and em?

The reference differs. rem is always relative to the root element's font size (16px by default, and it follows whatever the user has set). em is relative to the current element's font size: relative to the parent when used on font-size, and to the element itself when used on padding or margin. So em compounds as nesting deepens; rem does not.

Is px really unusable?

It is not a blanket rule. px suits 1px borders, cases where you must match a design mock exactly, and font sizes — because browser zoom scales the whole page anyway, which most users find comfortable. Sizes that affect layout should follow user preference, so spacing and font sizes are better in rem.

How many px is 1vw, and how does it differ from %?

1vw is 1/100 of the viewport width, so 100vw is the full viewport width. A percentage is relative to the parent container while vw is relative to the viewport — setting 10vw on a child that is 50% wide uses a completely different reference. Be careful with vw font sizes: because vw does not respond to the user's font-size preference, raw vw text ends up too small on mobile.

示例与注意事项Example & notes

一个例子A worked example

设计稿 375px 宽、按钮宽 88px:根字号 16px 时等于 23.4375rem,页面同时给出 vw 与百分比换算。A design at 375 px with an 88 px button equals 23.4375 rem at a 16 px root; vw and percentage values are given too.

注意事项Things to watch

相关问答More Q&A

该选 rem 还是 vw?rem or vw — which one?

需要跟随用户字号缩放用 rem;需要严格按设计比例铺满用 vw。Use rem when text must respect user font settings, vw when the layout must scale with the viewport.

支持小程序 rpx 吗?Does it support rpx?

支持,按 750 设计稿的换算规则给出 rpx 值。Yes — rpx values follow the standard 750-unit design width.

Further reading

觉得好用?Found it useful?