Middle
What does the EM unit depend on — the nearest REM or the parent font-size?
sobes.tech AI
Answer from AI
The em unit in CSS depends on the font size of the parent element, not the nearest rem.
emis a relative unit that scales relative to the currentfont-sizeof the parent.- If the parent has
font-size: 16px, then1emin the child element will be 16px. - Unlike
em,remalways refers to the root element (<html>), that is, itsfont-size.
Example:
html { font-size: 16px; }
.parent { font-size: 20px; }
.child { font-size: 1.5em; /* will be 1.5 * 20px = 30px */ }