Convert between px and rem with a configurable root size.
Convert pixel values to rem and back using a base font size you choose, and convert every px value inside a whole CSS snippet in one go. It helps front-end developers move fixed-pixel designs to scalable rem units that respect the user's browser font settings. The default base is 16px.
A rem is a CSS length unit equal to the computed font size of the root element, which is the html element. Browsers default that size to 16px, so 1rem is 16px, 1.5rem is 24px and 0.875rem is 14px. Because rem scales with the root size, layouts built in rem grow or shrink when a user raises or lowers the default font size in their browser, which is good for accessibility. Unlike em, rem does not compound through nested elements, so values stay predictable. Converting is simple division: rem equals pixels divided by the root font size, and pixels equal rem multiplied by it.
Values of exactly 1px (or -1px) are left as they are in the snippet converter because thin borders and hairlines usually should stay one device-independent pixel wide. Convert those by hand using the Pixels field if you really want rem.
Use the computed font size of your html element. Browsers default to 16px. If your CSS sets html to 62.5%, the effective base is 10px.
Values are rounded to four decimal places, for example 10px at base 12 becomes 0.8333rem. That is far more precise than browsers can render.
No. Only values written as a number followed by px are converted, and only px and rem are handled by the single-value fields.
The snippet converter replaces every number followed by px anywhere in the text, including media queries, so review those results, since many teams keep breakpoints in px or em.