Can I use responsive units like em and rem for margin and padding?


#1

Question

Can I use responsive units like em and rem for margin and padding?

Answer

We can use responsive units including em and rem for margin, padding, and other boundary and space properties like width.

We can use rem units for margin and padding when we want the margin and padding for an element to scale with the root font-size (the font-size set for the root, or <html>, element).

We can use em units for margin and padding when we want the margin and padding of an element to scale with the font-size of that particular element.