Font Test ✒

Parent size is 50px

Parent: Absolute 50px

Children size 0.5em

Children size 25px

Children size 1.5em

Children size 150%

Summary: 1em = 100%

Children size 1rem

Children size 16px

Children size 2.5rem

Children size 40px

Summary: 1rem = 16px

Box Test 📦

Parent size is 100%

Parent: Relatively 100%

Children size 10rem 10*1rem
Children size 10em 10*1em
Children size 160px 10*16px
Children size 100%

Summary: em comes from the printing paper world.
So, em, rem only relates with font size

Children size 10vw

Summary: we should use px, %, vh/vw for height/width

FAQ

max-width and min-width

The min-width and max-width are media features that correspond to a certain media type that has been specified in the media query. The min-width specifies the minimum screen width of a specific device, meanwhile, The max-width media feature states the maximum screen width of a specific device.

Why to use percentage in css?

The CSS data type represents a percentage value. It is often used to define a size as relative to an element's parent object. Numerous properties can use percentages, such as width , height , margin , padding , and font-size . Note: Only calculated values can be inherited.

Use of VW

VW is useful for creating full width elements (100%) that fill up the entire viewport's width. Of course, you can use any percentage of the viewport's width to achieve other goals, such as 50% for half the width, etc. VH is useful for creating full height elements (100%) that fill up the entire viewport's height.

EM vs REM

EM is relative to the parent element's font size, so if you wish to scale the element's size based on its parent's size, use EM. REM is relative to the root (HTML) font size, so if you wish to scale the element's size based on the root size, no matter what the parent size is, use REM.