Search code examples
htmlcssheightwidth

How do I know what height/width to set for CSS?


I don't fully understand how to determine rem, em, px, or %.

I know what each one means, but it's still unclear to me to know when to use each one. What are the criteria for knowing which ones to use?

Your input is greatly appreciated.


Solution

  • The units cm, px, pt etc are known as absolute length units and are used for exact sizes and would not change based on many factors like screen size. Units like vw, vh, % etc are known as relative size units and change based on the size of the screen you are viewing the page on.