Inputs
px24
Ready
A rem is a pixel count divided by the root font size. An em is the same pixel count divided by the parent font size. With both sizes at 16, 24px is 1.5rem and 1.5em, so the two units look identical and people treat them as twins. They stop matching the moment the parent is not the root.
Type the value in px, rem, or em. The page always prints all three. If the input is already rem, it multiplies by the root to recover pixels, then divides by the parent for em. A 24px margin on a 16px root is 1.5rem. Put that same 24px inside a component whose font size is 20px and the em becomes 1.2 while the rem stays 1.5.
Root and parent are both required because they answer different questions. Rem tracks the document, which is why a user who enlarges the root text scales rem-based spacing with it. Em tracks the element you are inside, which is why a button with font-size 14px makes 1em equal 14px even when the root is 16.
Value 24. Input unit px. Root font size 16. Parent font size 16.
px 24, rem 1.5, em 1.5. They match because both font sizes are 16.
Oddsock runs this in your browser. It is free, it does not upload the work, and it does not ask for an account.
Divide the pixels by the root font size. 24 / 16 is 1.5rem. To go back, multiply the rem by the root.
Rem divides by the root font size. Em divides by the parent font size. They are equal only when those two sizes are equal.
The parent font size changed. Rem ignores the parent. Em is pixels divided by that parent size.
If someone set the root to 10px so that 1rem equals 10px, type 10 as the root. This page does not assume 16 if you tell it otherwise.
Yes. 1.25rem at a 16px root is 20px. The page accepts decimals in the value and in both font sizes.