4 ms·
So should you just use em for everything?
by Kiro 13y ago
So should you just use em for everything?
- maaarghk 13y agoNot everything - this article is wrong that CSS defines em as being based on "m" [1] (includes actual quote [2] from w3c spec) [1] http://stackoverflow.com/a/4531441/1971539 http://stackoverflow.com/a/4531441/1971539 [2] The 'em' unit is equal to the computed value of the 'font-size' property of the element on which it is used. The exception is when 'em' occurs in the value of the 'font-size' property itself, in which case it refers to the font size of the parent element. It may be used for vertical or horizontal measurement.
- omnicognate 13y agoI'm the author of the article (the reponse not the original). I didn't say em is based on "m". All I said about em is: "(For completeness, I should mention here that the "em" and "ex" units are exceptions to the above. The lengths 1em and 1ex do vary relative to the other units, because they depend on the font in use.)" I'll update this to say "font size" as I didn't mean to give the impression that it was dependent the choice of font.
- maaarghk 13y agoI was nit picking to be fair. But font size certainly does clear up the ambiguity.
- blauwbilgorgel 13y agoem or relative font-sizing seems like a good choice. Also see rem [1] which was introduced with CSS3 to combat issues with font size compounding. Use pt for print stylesheets [2]. For a bit of ancient internet history: http://style.cleverchimp.com/font_size/points/font_wars.GIF http://style.cleverchimp.com/font_size/points/font_wars.GIF [1] http://snook.ca/archives/html_and_css/font-size-with-rem http://snook.ca/archives/html_and_css/font-size-with-rem [2] http://www.w3.org/Style/Examples/007/units.en.html http://www.w3.org/Style/Examples/007/units.en.html
- molf 13y agoThe rem unit is awesome! All the benefits of em (relative to browser text zoom level) combined with the benefits of px (does not change depending on parent element font size). If you don't need to support IE8 you should start using rem today.
- ars 13y agoNo. Because if you do, when you want to slightly adjust the font size, suddenly nothing fits on your page, and you have to fix the sizes of all the boxes. Use em when you don't care about the exact size, you just want some space. Em is also a poor choice for borders.