Pixels (px) Vs. Em
Okay so this is a highly debated topic between what I believe are perfectionists in their own regard. Unfortunately for the other group, I’m going to take the side of pixels. Here’s why:
When I build a web site, I write code for it to be viewed on a computer screen. If I make a mobile version of that site, I write code for it to be viewed on a smaller mobile-device screen. And in both cases I believe that my site should render in a pixel-perfect manner across all browsers. Because that’s what is intended of me. That’s what I get paid for.
The W3C recommends using EMs on sites because of their scalable nature. What most people don’t realize is that most of the W3C’s recommendations don’t get adopted by all browsers, and that browsers themselves are customizable software. So there’s no way of determining the final outcome when you use EMs. Pixels on the other hand always deliver the desired results.
Pixels have been criticized of being too rigid. But that’s exactly why I like using them. Because they’re 100% reliable. And I believe that as developers, our jobs end in making sure our web sites render perfectly across browsers. It is the job of the Operating System and browser to make sure the user gets a customized browsing experience. For example, I’m pretty sure visually impaired users and users who have large screen resolutions browse the Internet on a 200% – 300% zoom on their browsers. Unfortunately, that’s where our web technology stands today. What’s the point of making fonts bigger yet images stay the same size?
Mobile devices will continue to rise as a popular means of browsing the Internet. But most “computer” web sites are not meant to be viewed on a mobile device. Either because they’re designed that way, or because there have less bandwidth-heavy mobile versions of the site available. In both cases, pixels play a significant role in ensuring a perfect browsing experience on a mobile device. One must not forget EMs are calculated based on pixels. So its more a question of responsive design than calculation of font sizes.
There definitely are occasions where EMs trump pixels in terms of them being a measure and not a unit themselves. And they should be used in those situations. I don’t see why percentage values (%) based on pixels can’t be used in those situations either.
IMHO pixels should be the standard in web development, not EMs. Not only because of their reliability and ease of use, but also because the pixel is the unit based on which a web page is actually rendered, not hypothetically rendered.







benthvedt 6:22 am on February 13, 2012 Permalink |
Interesting point. I’m interested in web development, and I’m just now building my first website for someone, and I found myself preferring pixels over em’s in the margins and the borders of the pages as well.
junaidbhura 9:26 am on February 13, 2012 Permalink |
Great!
. All the best!