px to em converter em = px / parent
18px at an 18px parent is 1em. The same 18px at a 16px parent is 1.125em. 16px inside a 32px heading is 0.5em.
Nested em multiplies, so a child of 1.2em is not 1.2 times the root when an ancestor is already in em. This page uses the parent field. Rem on the same card still uses the root.
18 / 18 = 1em 18 / 16 = 1.125em 16 / 32 = 0.5em Rem/Px/Em Absolute Viewport Font-relative Resolution
Copy CSS
Copies the pixels field.
Common sizes
8px · 0.5rem 10px · 0.625rem 12px · 0.75rem 14px · 0.875rem 16px · 1rem 18px · 1.125rem 20px · 1.25rem 24px · 1.5rem 32px · 2rem
16 px, 1 rem, 1 em
px in em at a 16px parent and an 18px parent px em (parent 16px) em (parent 18px) 8 0.5 0.4444 10 0.625 0.5556 12 0.75 0.6667 14 0.875 0.7778 16 1 0.8889 18 1.125 1 20 1.25 1.1111 24 1.5 1.3333 32 2 1.7778
Also see px to rem , rem to px , and em to px . The other unit groups are on Units .
Questions How do you convert px to em? Divide px by the parent font size. em = px / parent. 18px at an 18px parent is 1em. At a 16px parent, 18px is 1.125em.
Why isn’t 16px always 1em? 1em equals the parent font size, which is not always 16. 16px inside a 32px heading is 0.5em.
Do nested em values add? They multiply. A child of 1.2em is not 1.2 times the root when an ancestor is already in em.
How is this different from px to rem? rem divides by the html font size. em divides by the parent.