user319198
user319198

Reputation:

Giving width/height in pixels/percentage of HTML content

What is the exact difference between giving width/height of html contents in pixels/percentage?

Are both of them same?

Are they play any role in browser compatibility ?

if different then which one is best?

Upvotes: 1

Views: 2173

Answers (3)

Tarun
Tarun

Reputation: 5514

The difference comes in IE, and when using zoom feature.

hit ctrl + '+' key or ctrl + '-' and you will see everything expanding, if everything is in pixel, then it will create empty space and your elements wont expand, while if they are in percentage, they will expand.

Also, if any of the div/container has height/width set in absolute values {pixels} then all their child elements automatically becomes fixed.

The difference is same as using em instead of px for fonts.

Upvotes: 1

Jeaf Gilbert
Jeaf Gilbert

Reputation: 11981

in pixel: fixed size

in percentage : fluid to its parent element

I've never found different appearance between browsers related to this thing.

Which is the best, depends on your need.. whether you want to make it fixed size or fluid.

Upvotes: 1

Mudassir
Mudassir

Reputation: 13174

They are different. If you use pixels then, its an absolute measurement and will be rendered irrespective of the browser's window size. And percentage is a relative measurement which will be rendered with respect to the browser's window size. If you want to show some element to always appear in a fixed size, then use pixels, else use percentage.

Upvotes: 0

Related Questions