px or em?
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
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... %.
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... %.
Re: px or em?
Oddly enough, it looks like you should use neither.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.
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.
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.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.
For once, I am not sure (pun intended), and more discussion is warmly invited.
Thanx for that
Thankyou for that useful information. I have always used px. But I think i will need to change this habit.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
http://www.forum4designers.com/archive2 ... 80038.html -> argument against ex:
More specifically,
http://css-discuss.incutio.com/?page=UsingFontSize
http://css-discuss.incutio.com/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.
More specifically,
http://css-discuss.incutio.com/?page=UsingFontSize