Reputation: 855
In the book bulletproof web design the author mentions that specifying font size in pixel is not the right way from the point of accessibility.
Later in the book, he uses the margin and padding in pixels - My question is since pixel is relative to the resolution of the device - would that remain consistent - when accessed from different devices?.
Thanks to explain.
-- Update: Read the later notes by the author: The author "Try using ems for margins, padding, line height, and so forth to provide true scaling of your design (and not just text), regardless of font size."
It seem's that there is no one answer to this - just that if older browser support /accessibility issues are taken into consideration then relative measurements are preferred.
Upvotes: 2
Views: 632
Reputation: 40671
There's a lot of opinion but no one best right/wrong way to do it. It all depends on context...the content, the site, the audience, the code, etc.
There's nothing inherently inaccessible about defining your fonts in pixels. There was a time when it was hard to size the type via user-preferences in IE6, but that was a failing of IE6, not the px unit of measurement. Many folks now prefer to spec type in px (as do I) as it can make things easier on large sites with massive amounts of inherited CSS and a deeply nested DOM.
As stated, em is a measurement relative to the size of the type. So if you base padding and margins using ems, they will change in proportion to base font size of your page. Is that good? Again, it depends on your particular page layout and needs.
Upvotes: 2
Reputation: 4613
That's only a problem in IE6. All the newer browsers zoom properly, and enlarge text, even when it's set in pixels.
Only setting font sizes in em doesn't increase accessibility in any other browser. However, it's no harm in any browser, so if it suits you, stick with it.
Pixels in css aren't really pixels, they're a percentage of the viewing angle. So hi-res devices will show your content fine, it won't appear tiny if you set pixel sizes.
Reference:
A Pixel is Not a Pixel - Quirksmode
W3C Unit Definitions - see the explanation of the pixel unit for a free headache
Upvotes: 1