What's the difference between 'px' and '%' while setting the width in an attribute? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's the difference between 'px' and '%' while setting the width in an attribute?

attribute specifications

22nd Nov 2017, 5:23 PM
Meghna Kulkarni
Meghna Kulkarni - avatar
5 Answers
+ 10
Main difference is that % helps u to create a responsive web design. If u set the div width in % that proportions will be the same when screen resolution will be changes
22nd Nov 2017, 5:33 PM
Aleksej Donchuk
Aleksej Donchuk - avatar
+ 8
Yep) if u using px thats a static equal size on differerent resolutions
25th Nov 2017, 7:22 AM
Aleksej Donchuk
Aleksej Donchuk - avatar
+ 7
no) u may used px but I rated used px for vertical sizes
22nd Nov 2017, 6:31 PM
Aleksej Donchuk
Aleksej Donchuk - avatar
+ 1
does it mean that the width as pixel will not be changed with screen resolution?
22nd Nov 2017, 5:35 PM
Meghna Kulkarni
Meghna Kulkarni - avatar
+ 1
width: 10% mean that the element has 10% of the width of it's parent node, 10px are 10px, I think this is obvious😊
22nd Nov 2017, 7:20 PM
Jonas Schröter
Jonas Schröter - avatar