When specifying a 0 value in CSS, should I explicitly mark the units or omit?

后端 未结 8 1039
旧巷少年郎
旧巷少年郎 2020-12-16 09:13

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\' an

8条回答
  •  有刺的猬
    2020-12-16 09:42

    In current browsers developer tools you can easily tweak the values live with the up/down cursor keys, but if you specify 0 without a unit, then it will not work, as the browser will not know what unit do you prefer, and setting 1, 2... without a unit has no meaning.

    That is why I am always specifying the unit nowadays on zero values too. Any CSS minifier will change that to 0 on minification so you don't even need to care about it.

提交回复
热议问题