Size in CSS (px, em, vh, vw, %) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Size in CSS (px, em, vh, vw, %)

I have only ever used pixels but after seeing the questions posted by others, now I am wondering if pixels is outdated? Is one superior to the rest or are there different advantages to each?

20th Dec 2019, 3:11 PM
Joshua Morgan
Joshua Morgan - avatar
5 Answers
+ 1
in CSS PIXELS are used for initial size, and em is used in comparison of pixels. like if text is 50px and next text you want is 25px then you can use 0.5em. there are viewports vh , vw , vmin and vmax. viewport height and viewport width.
20th Dec 2019, 4:34 PM
Needhi Wadhs
Needhi Wadhs - avatar
20th Dec 2019, 3:43 PM
Gordon
Gordon - avatar
0
Correct me if I am wrong. Em would be great for scaling text, pixel is good for small things like lines and viewport is good for page construction? Am I close?
20th Dec 2019, 3:59 PM
Joshua Morgan
Joshua Morgan - avatar
0
Is there any reason not to use pixels?
20th Dec 2019, 8:06 PM
Joshua Morgan
Joshua Morgan - avatar
0
For displaying appropriately for different screen size
21st Dec 2019, 5:18 AM
Gordon
Gordon - avatar