3 ms·
> but CSS has an obscure unit that makes our life a little bit easier I've been out of the HTML game for a while, is ch the new em? em has been around for a wh
by 22c 6y ago
> but CSS has an obscure unit that makes our life a little bit easier
I've been out of the HTML game for a while, is ch the new em? em has been around for a while.
I understand that they are slightly different, but is there a strong reason to use one over the other?
- SpaceNugget 6y agoch is based on the width of a "0" character, em is based on the font size, which is the height of the character. for setting widths of things that contain text ch makes more sense. For padding, spacing, font sizes, inline symbols, and that kind of thing, em makes more sense.
- desert_boi 6y agoAn em is historically based off the width of the letter M in a typeface. https://iamvdo.me/en/blog/css-font-metrics-line-height-and-vertical-align https://iamvdo.me/en/blog/css-font-metrics-line-height-and-v... is a fun deep dive into font sizing, which is pretty hairy.
- 22c 6y agoThat was my understanding as well. em was used for width and ex used for height.