40px to em
40px = 2.5em
At the browser default font size of 16 px. Change it and this number changes — see below.
How it is calculated
One px is 0.0625em, so:
40px × 0.0625 = 2.5em
Reversing it, 2.5em × 16 returns 40px.
40px at other font sizes
em is measured against the element's own font size, inherited from its parent unless it sets one, so the answer above holds only while that is 16 px. Nested elements each compound on their parent, so this is the value for one level, not for the whole tree.
| Font size | 40px equals |
|---|---|
| 14 px | 2.8571em |
| 16 px (default) | 2.5em |
| 18 px | 2.2222em |
| 20 px | 2em |
| 24 px | 1.6667em |
Nearby values
| px | em |
|---|---|
| 20px | 1.25em |
| 24px | 1.5em |
| 28px | 1.75em |
| 32px | 2em |
| 36px | 2.25em |
| 40px | 2.5em |
| 48px | 3em |
| 56px | 3.5em |
Frequently asked questions
What is 40px in em?
2.5em at the default 16 px font size.
How is 40px converted to em?
Multiply by 0.0625: 40 × 0.0625 = 2.5. To go back, multiply 2.5 by 16.
Is 2.5em always the answer?
No. em is relative to the element's own font size, inherited from its parent unless it sets one, so 40px is 2.5em only while that is 16 px. The table above gives the value at the sizes you are most likely to meet.