'property: 0' or 'property: 0px' in CSS?

后端 未结 9 1716
无人及你
无人及你 2020-11-28 10:38

I\'ve seen this notation used a lot, and I was wondering, is there is any notable difference between these two notations?

element#id
{
  property: 0;
}
         


        
9条回答
  •  迷失自我
    2020-11-28 10:41

    You can use either - my best advice is not to worry too much but be consistent in doing it either one way or the other. I personally prefer to specify '0px' for the following reasons:

    • Using 0px makes things more consistent with all of the other 'px' sizes you've specified
    • It's also more verbose and makes it very clear that you're setting a zero length rather than a 'switch this off' flag
    • It's slightly easier to tweak a '0px' value to make it another value if required

提交回复
热议问题