Best practice use for width and height? % or vh and vw? or em?

So I’ve been playing around with CSS and I’ve come to realize that % and vh and vw are almost identical but I also don’t know if I should use em. What’s the best practice in the field?

“almost identical” is an overstatement.

Yes they are measurements that are relative.

But, where % relates to the size defined in the parent element. Meaning its size changes with each iteration.

vh relates to the height of the window

vw relates to the width of the window

These parameters are used to make your webpage responsive, i.e. readable in different sizes of viewing windows (mobile, desktop, tablet).

1 Like

is it better to use % or vh/vw?

That depends entirely on what it is you want to achieve in your website aesthetic design. There no such thing as a better parameter.