CSS CSS Basics The Box Model Margins

Ryan Cross
Ryan Cross
5,738 Points

em values;

I see how they work but I'm not seeing the advantage over a px value. Why not skip the calculation?

1 Answer

Steven Parker
Steven Parker
186,966 Points

The advantage of em units is the dimensions you set will adapt to the font size. With pixels it will never change.

according to the video there is no absolute value so how does the em and rem value relative to ,steven ?

Steven Parker
Steven Parker
186,966 Points

If I understand your question, rem values are relative to the default font size of the document, and em values are relative to the font size of the parent element.

oh got that , tks u , at first i see no default value , so i don't know which base do rem and em lean on cause every font-size are rem and em

Steven Parker
Steven Parker
186,966 Points

If not explicitly set in the CSS, 1rem will be equal to the default font-size provided by the browser (usually 16px).