0

Just curious as to which is better to use in css ... width % or width in px?? Are there any known browser compatibility issues that might prompt a preference between the two?
Thank you in advance for you input. :)

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by fuston05
0

Sometimes it is better to use % sometimes px.
For example. If you wish that your div has same width as page in browser than you will use %. If you wish that your div has same width as, for example, background image you have prepared for it than you will use px. Also if you have some small div that is inside of the bigger one and you wish that smaller div has same width as bigger one you will use %. If you have thumbnails placed in divs, and you wish that all thumbnails have the same width than you will use px, and also overflow:hidden.

0

As far as I know, all browsers recognize percentages and pixels with no problem.

I like to use percentages for page widths and such. If not, some users can have very bad experiences visiting your site.

0

It's a matter of preference really. Sometimes px is nice because you know the unit of measure and you don't necessarily need to make any calculations. Sometimes percentages are nice because it's generally a friendlier browser experience for "liquid" layouts.

Large areas where you know you want the width to max out the parent element you can easily use width:100%; instead of calculating the number of pixels you would have to use.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.