This is more of a 'philosophy' argument, but I'd like to know what the recommended practice here. I'm not setting it up as a Wiki yet in case there is an 'official' answer.
Obviously, there is no difference between 0px and 0em or whatever, so one could simply specify 0 and the units are redundant (see CSS difference between 0 and 0em). Some of the folks who answered that question argued that one should always omit the units.
However, it seems to me that omitting the unit is more error-prone, since a later change may accidentally omit the unit. It is also less consistent with non-zero elements elsewhere in the document.
I argue you should also omit the units.
From a programmer's perspective, 0 == null == none == false
, where 0px == 0px
only.
Which means that if you specify a border width of 0
then no border will be there, but if you specify a 0px
border, then a border of 0 px will be created (that's the idea behind it, in reality 0px
gives the exact same result like 0
).
0
makes it easier to read as it is easily distinguishable from normal unit'ed values.Conclusion: Omit the units in 0. They're not needed and confusing.