rem and em units in CSS?rem always refers to the root element's font size (usually <html>), making it consistent across the page. em depends on the font size of the element it is used on, so it can compound if nested.
<p> inside .container if the root font size is 16px?html { font-size: 16px; }
.container { font-size: 1.5rem; }
.container p { font-size: 2em; }The root font size is 16px. .container font size is 1.5rem → 1.5 × 16px = 24px. The p inside has font size 2em → 2 × 24px = 48px.
div to 5% of the viewport width?vw stands for viewport width, vh for viewport height.5vw means 5% of the viewport's width. vh is relative to viewport height, rem and em are relative to font sizes.
vw and rem mean.50vw sets width to 50% of viewport width. 10rem sets height to 10 times the root font size. Other options mix viewport height or relative to element font size incorrectly.
rem units scale with the root font size, which respects user browser settings for accessibility. Fixed px units do not scale, and viewport units can cause inconsistent sizing.