Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

`em` is a relative unit that can change depending font-size of the given element while `pt` is an absolute value. the W3C does not recomend using any absolute value such as `pt` for text rendered on screens. only relative values or `px` should be used. [0] I would suggest this very helpful article on the topic, it provides a lot of good info and context on this subject.

[0] https://www.w3.org/Style/Examples/007/units.en.html



> only relative values or `px` should be used.

Both px and pt (and cm, mm, in etc.) are absolute (in the sense that they don't depend on the current font size, only on the pixel density and scale factor of the display). So there is no reason to prefer px to the other units.

In traditional typography, pt is relative to the size of a font, but in CSS it is just an absolute measurement like px.

See: https://drafts.csswg.org/css-values-3/#absolute-lengths

The tutorial you link to is wrong, which is weird since it is written by the inventor of CSS! It might be because it is out of date and reflect the original intention of CSS, not how it actually turned out.

Originally, the intention of CSS was that px should correspond to a pixel and pt/mm/in to physical dimensions, so the ratio between px and pt would vary depending on the pixel density. But people started to specify font sizes in px, which meant text would just become unreadably small when high-density displays were introduced. So instead px was redefined as a physical unit rounded to nearest pixel, and the other absolute units defined relative to this.


Historically, the term "em" goes back to the days of printing with metal type, and referred to the width of a capital "M" in the current typeface and point size:

https://en.wikipedia.org/wiki/Em_(typography)

There's also a unit called an "en", which was based on the width of "N":

https://en.wikipedia.org/wiki/En_(typography)




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

Search: