News for hackers. Stuff that matters.
Re:User Interface Typography by BoppreH on Monday December 11, 2023 @09:17AM (#38600818)
I've just finished reading Refactoring UI, and the author has a good point against `em`: nested uses lead to fragmented sizes.

Let's say you have a fixed list of font sizes (and you probably want to), that goes like this: 0.75em, 0.875em, 1em, 1.25em, and 1.5em. It's all good if you have an element with `font-size: 1.25em`, because that's on the scale. But if a nested element has 0.875em, it'll actually be 1.25*0.875 = 1.09375em, because it'll be relative to the parent font size.

So if you don't want your UI to have 17 different font sizes with fractional pixels, "absolute" units like px or rem are preferable. They still don't map 1:1 to screen pixels, so it shouldn't be a problem for high DPI displays.

Re:User Interface Typography by arp242 on Monday December 11, 2023 @10:41AM (#38601545)
The "rem" unit fixes that: it's "relative em" and relative to the root rather than parent. It's supported everywhere (even IE) and for new projects you should probably always use "rem" and never "em".
Re:User Interface Typography by BoppreH on Monday December 11, 2023 @12:43PM (#38602740)
You gotta love CSS naming, where "relative em" is the version of "em" that is not relative to the parent.
Re:User Interface Typography by kaelig on Monday December 11, 2023 @01:39PM (#38603593)
That would have been a fun one, but rem stands for "root em"!
Re:User Interface Typography by BoppreH on Monday December 11, 2023 @02:26PM (#38604272)
That's weird, I confirmed it on https://drafts.csswg.org/css-values before posting that comment, but now I can't find it anymore. Thanks for the correction.