3 ms·
This isn’t a problem though. Why would the browser assume you’re subtracting px and not em or rem or most obviously %? Note your preprocessor may be overly amb
by ethanbond 4y ago
This isn’t a problem though. Why would the browser assume you’re subtracting px and not em or rem or most obviously %?
Note your preprocessor may be overly ambitious with stripping units, which I think is frankly a dumb linter rule always, but that’s not the browser’s fault.
- zamalek 4y ago0 is 0 in all absolute units.
- danaris 4y agoBut why should the browser have an exception for that, when subtracting zero is a no-op in the first place, and thus is pointless to even be asking it to do?
- SeanLuke 4y agoBecause it has the exception for zero everywhere else except there. It's inconsistent. IMHO the issue is that an exception for zero exists at all. Units should be required in all places.
- seba_dos1 4y agoIt doesn't. Lengths are the exception that allows unitless zero, not the other way around.
- zarzavat 4y agoBecause it’s valid in all other contexts.
- warp 4y agoBecause browsers themselves have set that expectation by accepting unitless 0 in most (all?) other places in CSS. e.g. "margin: 3px 0 4em 0" is a valid way to set the right and left margins to 0px.
- ethanbond 4y agoThis is a darn good answer! :)