Hacker News new | past | comments | ask | show | jobs | submit login

So should you just use em for everything?



em 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

[1] http://snook.ca/archives/html_and_css/font-size-with-rem

[2] http://www.w3.org/Style/Examples/007/units.en.html


The 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.


But note that px is also relative to the zoom level, as unintuitive as that sounds.


Not to the text zoom level.


modernizr + css-remunit polyfills and you can start using rem today. :)


Not 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

[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.


I'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.


I was nit picking to be fair. But font size certainly does clear up the ambiguity.


No. 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.




Consider applying for YC's first-ever Fall batch! Applications are open till Aug 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: