Click to See Complete Forum and Search --> : EM's versus pixels


Alexpte
06-25-2005, 05:14 AM
Hi

I'm designing a site at the moment, and have been told that i should use em's for font sizes rather than pixels.

Is this correct? And if it is, what are the advantages of using EM's and the disadvantages (if there are any).

Thanks a lot

Fang
06-25-2005, 05:31 AM
http://www.w3.org/QA/Tips/font-size

spidermatt
08-17-2005, 07:42 AM
ems are a general measurement that can be read by different sized screen and browsers etc and interpreted by the output media to give it a size relative to that media. Pixels however are a strict measurement (as you know). If you are to assign pixels to fonts then different sized screen and browsers will distort the text in weird ways usually by squashing it untill it is no longer readable. The cases in which this happens however would be few but you never know who is viewing your site and on what so to be on the safe side use ems for your fonts. Its all to do with accessability so it is an important thing to take note of in the future! hope this helps!

felgall
08-17-2005, 04:30 PM
Using EMs means that if your visitor needs to make the text bigger so they can read it they can. Using pixels means that the text will display using the specified number of pixels regardless of what the user wants. If their screen is set to 1000 pixels to the inch (no screen resolution goes this high yet but it could be soon) then the text would be microscopic. Even points is a better choice than pixels since at least it is independent of screen resolution although not changable by visitors without overriding the whole stylesheet.

NogDog
08-17-2005, 04:41 PM
Note that an em by itself is meaningless; it's size is coupled to the applicable font size of the element in question. If the current font size is 12px or 15pt or 0.2in, then the em will be roughly that size (12px, 15pt, or .02in)*. Then if the user increases/decreases the font size of his browser display, any elements using em units for any dimensions should have those dimensions increased/decreased in proportion to the new font size.

If you assign a font-size of 2em, then that means the font-size for that element will be twice the size of its default font.

____________
* The name "em" comes from the dimensions of a capital "M" within a given font style and size.

LJK
08-18-2005, 12:47 AM
Hi -
Call me crazy, but I usually set font-size:100%; in the body css, then set it from there in following elements - which may not be the greatest choice, but at least no matter what the user has it set for, the text will be proportional. [Line-heights I do w/ em's, tho - and letter-spacing in px.]

El