DS89 DS89 - 1 year ago 82
HTML Question

When is it okay to use percents in css?

I've notice that there are two different methods of quantifying the layout in CSS, that is by percentage and pixels. I know that it depends on which one that is being used, it would change the layout. Under which circumstance should one be used over another and is there a uniform standard if there is a preference?

Answer Source

For responsive design for example, using percents is the way to go, as elements having, say, a width: 50%; will always use half the container on any device, whatever the size, as opposed to, say, width: 400px; which would be messed up in a small size device.

But of course sometimes you want to use pixels to define an element to always have a fixed width. It really depends on the use case. But the main thing to have in mind is how the element will adjust in different screen sizes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download