About this tool
Type a value and unit to see it in every other CSS unit at once. Relative units depend on context, so set the root font size, the parent font size and the viewport size to match your design. Below, paste a stylesheet to convert all its pixel values to rem in one go.
Absolute and relative units
- Absolute:
px, and print units defined from it:1in = 96px,1pt = 1/72in,1pc = 12pt,1cm = 96px / 2.54,1Q = 1/4mm. On screens, a CSS pixel isn’t a physical pixel; print units only match real sizes on paper. rem: relative to the root (html) font size, 16px by default in every browser.em: relative to the current element’s font size (the parent’s, when used forfont-size), so it compounds when nested.%: here, relative to the parent font size, as forfont-size. For widths, percentages refer to the containing block instead.- Viewport units:
1vwis 1% of the viewport width,1vh1% of its height, andvmin/vmaxuse the smaller or larger side.
Why use rem for font sizes?
People with low vision often raise their browser’s default font size. Sizes in rem grow with that setting; sizes in px ignore it. Using rem for font sizes (and often spacing) respects the user’s choice, which is also a WCAG requirement for text resizing. Borders of 1px are usually best left in pixels so they stay crisp.
FAQ
How do I convert px to rem?
Divide by the root font size: with the default 16px, 24px is 24 / 16 = 1.5rem. Change the root size above if your site uses a different one.
What is the difference between em and rem?
rem is relative to the root element’s font size, so it is the same everywhere. em is relative to the element’s own (or parent’s) font size, so it compounds in nested elements.
How many pixels is 1pt?
1pt is 1/72 inch and CSS defines 1 inch as 96px, so 1pt = 1.333px and 12pt = 16px.
Should I use rem for everything?
rem is best for font sizes and often for spacing, so layouts scale with the user’s text size. Thin borders and shadows usually stay in px.
Is 1vw always 1% of the screen?
It is 1% of the viewport width, which includes the vertical scrollbar on desktop. That is why 100vw can cause horizontal scrolling.