Page 1 of 1

px or em?

Posted: Tue Jun 28, 2005 2:00 pm
by Ree
which is a more commonly used unit - em or px? or maybe there are specific cases when one or another should be used? would like to recieve your input on this.

Posted: Tue Jun 28, 2005 2:29 pm
by Chris Corbyn
It depend on what you're doing.

For layouts I *almost* always would use px since the geometry can be critical.

I'm gonna slide slightly off-topic and bring in font-talk. pt vs. em... always always always use em for font sizes if it's something that's part of the main content of the page. pt font sizes are rendered differently across the operating systems and can make impossible reading on some system where it looks nice on others. Using pt also *generally* prevents the user from using the increase/decrease font size option in their browser and so you're putting a large rock on top of any accessibility ideas you may have considered in your design.

Layouts... px yes, or for full-width designs... %.

Posted: Tue Jun 28, 2005 3:00 pm
by Ree
yes, i indeed had in mind fonts when i posted, just forgot to mention. :P

Re: px or em?

Posted: Tue Jun 28, 2005 3:36 pm
by Roja
Ree wrote:which is a more commonly used unit - em or px? or maybe there are specific cases when one or another should be used? would like to recieve your input on this.
Oddly enough, it looks like you should use neither.

px is non-relative, which means that users can't view the text larger if they need to. (It locks the size).

em on the other hand is relative, and is thus cool. It lets the user do what they want.
MozillaKB wrote: However, 1 em is 10.06667 pixels, and 1 ex is 6 pixels. Therefore, ex units are recommended over em units, since they are more easily converted into evenly-rounding pixel values.
So it looks like ex is better! Personally, I've almost always used em's, and I see other places where they say different things about em units.

For once, I am not sure (pun intended), and more discussion is warmly invited.

Thanx for that

Posted: Fri Jul 15, 2005 6:31 pm
by thedamo
Thankyou for that useful information. I have always used px. But I think i will need to change this habit.

Posted: Fri Jul 15, 2005 6:37 pm
by Ambush Commander
http://www.forum4designers.com/archive2 ... 80038.html -> argument against ex:
em (and ex) are in theory just as good as % but in practice they
trigger a few more browser bugs, so % is preferred for font-size. Use
em for scalable derived styles (such as padding). ex is further
screwed on several platforms where it is just treated as 0.5em rather
than as the correct value for the font in question.
http://css-discuss.incutio.com/
More specifically,
http://css-discuss.incutio.com/?page=UsingFontSize