Is pixel the same thing as % | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Is pixel the same thing as %

html

25th Aug 2018, 1:36 PM
Muhammed Sodiq Akande
Muhammed Sodiq Akande - avatar
13 Answers
+ 7
An object styled using px is fixed according to the size of pixels on a device. An object styled using % is relative to its container/max dimensions, and will adjust to fit different containers. An object of height 50px is just what it is. An object of height 50% would span half its container.
25th Aug 2018, 1:42 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
Nope they are different
26th Aug 2018, 6:03 PM
Unknown
+ 4
thanks
25th Aug 2018, 1:47 PM
Muhammed Sodiq Akande
Muhammed Sodiq Akande - avatar
+ 4
I assume you know that our screens are made of pixels. Assume you have a screen of length 1000 pixel. Now an element with 50% length would cover half the screen and an element with 50 px length will cover only 1/20th (5%) of the screen.
26th Aug 2018, 11:47 AM
Rugved Modak
Rugved Modak - avatar
+ 4
No...pixels are defined according to resolution of the device but % is used relative to the block you are storing the object
29th Sep 2018, 6:34 AM
Shubhanshu
Shubhanshu - avatar
+ 3
no, % means percentage of maximum width lets make an example <div style="width:100px;"> <div style="width:50%;"> </div> </div> the first div will be 100 pixels in width the second one will be 50 pixels, because: >the maximum width in % is inherited and is 100 pixels >we took 50% of the maximum width, so it will be 50 pixels
25th Aug 2018, 1:43 PM
Roel
Roel - avatar
+ 3
no bro.pixel is different and % is different.in pixels we can give how much pixels we divide in display.EG:height=50px.in this the display will divided into two part one part will divided into 50 pixels.and another part will divided into remaining pixels.for % EG:height=50%.in this the program will first convert % into pixels.then it will divide the display.in this the display will divided into half screen .because 50% means half.so it will divide into half screen one side and another half into another side
25th Aug 2018, 7:10 PM
Spidey K💚K💚😉
Spidey K💚K💚😉 - avatar
+ 3
Pixels are an absolute length. 1 pixel is equal to 1/96 of an inch . Percentages are relative to another value. 1% is 1/100 of another length. Pixels is a fixed value. For example, the header on this site is fixed to 980px. Percentage, well, it is a part of a parent measure where the browser is the outermost parent. Pixel value is fixed however percent value may varry according to your screen resolutions.
25th Aug 2018, 9:59 PM
Manish Kumar
Manish Kumar - avatar
+ 3
nope.. pixel is the fix thing it can be vary with screen size bt % very with screen size if width is set to 50% then in desktop of 1024px its with 512px and in mobile of 320px resolution gets 160px
26th Aug 2018, 10:19 AM
Aarav Raj
Aarav Raj - avatar
+ 2
Pixels (px) : Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution). Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser. One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices. Percent (%) : The percent unit is much like the “em” unit, save for a few fundamental differences. First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.
26th Aug 2018, 8:56 AM
AL Araf
AL Araf - avatar
+ 2
thanks
26th Aug 2018, 12:16 PM
Muhammed Sodiq Akande
Muhammed Sodiq Akande - avatar
+ 1
yes my friend they are same. it's up to you what do you choose b/w px and %
30th Aug 2018, 12:30 PM
<html>SAMEER POSWAL</html>
<html>SAMEER POSWAL</html> - avatar
- 2
yes no problem
28th Aug 2018, 4:57 PM
shiva thakur
shiva thakur - avatar