3 ms·
I remember seeing some video enumerating all the dozens and dozens of units CSS has now, but I'm a simple man, and I just use rems for everything.
by karaterobot 2y ago
I remember seeing some video enumerating all the dozens and dozens of units CSS has now, but I'm a simple man, and I just use rems for everything.
- alwillis 2y agoThe short answer: rem is for global sizing and em is for local or component level sizing.
- runarberg 2y agoWhy would you deny your self font aware units (such as cap or ex) or inline relative units (such as ch)? Column width form example are very intuitive to see in ch units. 30-42 ch fits roughly 30-42 characters on a line and is nice to read. 120+ ch is too long and is perfect for max-inline-size of a container with a lot of body text. Specifying that in em is kind of just guessing. Then there is viewport relative units such as vw and vh and the new container relative units cqw, cqh etc. and of course %.
- alwillis 2y agoI agree with all of that; I was responding to a comment someone made about only using rems for everything. I probably posted it to the incorrect thread.
- qingcharles 2y agoEvery time a new unit is added I find a use for it almost immediately to clean up my designs and clean up my CSS. I've practically rid myself entirely of media selectors for viewport sizes.
- rickstanley 2y agoI think I saw all of them in a CSS Tricks post, but I too took the "simple" way. At first, I marvelled at the complexity of CSS units, but it didn't take long for me to tire of them. Some tricks are still useful though, like using `calc` with `v[w|h]`, `[r]em` and `%`, that yield favourable and interesting results; fortunately you only have to remember and understand a subset of units to take advantage of this.