5 ms·
> New viewport units how many units does CSS have?? Shouldnt part of the improvement be to simplify and declutter the web's fundamentals?
by jdrc 5y ago
> New viewport units
how many units does CSS have?? Shouldnt part of the improvement be to simplify and declutter the web's fundamentals?
- silviot 5y agoObligatory XKCD: https://m.xkcd.com/927/ https://m.xkcd.com/927/
- onion2k 5y agoApart from the duplicates (cm, inches, etc which can all be derived from mm with a basic calc) they all do different things. vw, vh, vmin, and vmax are useful for filling a screen, px is obviously related to the screen size, em, rem, ch and lh are relative to the current font or root font. There isn't much clutter there.
- esperent 5y agoYou're missing quite a few. Here's all the size related CSS units I could find: em rem ex rex cap rcap ch rch ic ric lh rlh vw vh vi vb vmin vmax And soon also: dvh lvh svh Taken from here https://github.com/fisker/css-units-list/blob/main/index.js https://github.com/fisker/css-units-list/blob/main/index.js
- jdrc 5y agowhat about flex units fr etc? they dont count?
- esperent 5y agoPlease list any I missed. I only listed things you could set as width, height etc. There's also units like Hz and so on.
- onion2k 5y agoI was illustrating how most of them aren't clutter. They do different things. This list just goes further to show that point - all the text related units refer to different aspects of the text, and they all need root and local versions. Same for screen space units like vw, vh, and so on. Any unit where you can't derive one from another means you need both. There are some where you can do that. Absolute lengths like mm, cm, inch etc could just be one unit. Same for deg, rad and turn. Mostly though, CSS units are very well thought out, and it's easy to understand why the length units are included (USA vs metric).