views:

45

answers:

2

What em can do which can't be done by %?

+3  A: 

Ems are useful because they're very high precision and directly related to the font size.

Check out the always-insightful A List Apart for some good advice.

Eli
Very nice, the link
Liao
+1  A: 

Each offers a different way of determining a value, and each has certain advantages/disadvantages. These also vary depending on the particular property in question.

For font-sizing, there's little to differentiate the two: both will size the font relative to its parent's font, and both use the same value (<number>) so should be equally precise.

For other properties, such as width, the difference is very significant. Percentage values effectively provide the ability to vary according to window size. Em-based values allow you to vary dimensions according to font-size. The former is great for handling a range of output devices. The latter is great at maintaining consistent line lengths.

Bobby Jack
so em is better than % for mobile devices.
metal-gear-solid
Most current mobile devices tend to 'fix' wide layouts anyway, although I don't know the full details, so I'd advise testing. Percent for layouts is probably better for maximum cross-browser compatibility,
Bobby Jack
i'm asking in terms of text sizing
metal-gear-solid
shouldn't make a difference, then
Bobby Jack