Click to See Complete Forum and Search --> : EM's or PX's?
novemberGrey
11-22-2006, 04:41 PM
I've been looking around at other peoples CSS and I've noticed a good majority of people use the unit "em" instead of "px". I dont really understand what "em's" are and I was wondering if they were better to use than pixels?
WebJoel
11-22-2006, 05:06 PM
And "em" is a size format of a character that occupies approximately the samew space as the letter "M" (hence, it's name).
The advantage of using "em" (or "%" too) is that it allows browsers and persons using them to re-size the fonts for visual aid. -If you are near-sighted and cannot read what's on your screen, if the web-writer used "em" to define his/her font-size, the user re-size the text for easier reading. You can't do that if the font-size is defined as "px". It is Accessibility. :)
David Harrison
11-22-2006, 05:28 PM
As a general rule, use % to specify font size, use em or % where possible to specify dimensions.
novemberGrey
11-22-2006, 06:03 PM
so I should just use "em" for font sizes?
Centauri
11-22-2006, 06:04 PM
You can't do that if the font-size is defined as "px".
It doesn't make any difference in a DECENT browser........ :)
I usually spec text size in px to get a base starting point (ensuring that the size picked is not too small - I consider the text in the ad boxes to the right of the forum pages here is too small) as you cannot tell what the user has set for their browser default - a h1 header with a large base size can be enormous and rediculous, and conversly smaller sizes can be way too small if the default is already small. As I mentioned, a decent browser will still allow you to resize text anyway.
ems are quite handy for defining container and margin / padding sizes so they accomodate any user alteration to text size.
Cheers
Graeme
Jeff Mott
11-22-2006, 06:28 PM
It doesn't make any difference in a DECENT browser........That is true. Pixels for font size is often described as inaccessible in a very broad sense, but that's not accurate. It's nothing more than an IE bug that makes the px unit a bad choice.
I usually spec text size in px to get a base starting pointThat px-based starting point is enough to disallow IE users the right to control their font size.