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

后端 未结 9 1719
无人及你
无人及你 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:40

    As far as I'm aware there is no difference between them, since 0px = 0em = 0ex = 0% = 0. It's purely up to you, as the developer, to decide what you like best (unless you have corporate coding standards that you need to follow, of course).

    From most of the code samples I've seen, most people use the unitless version. To me, it just looks cleaner. If you're pushing a significant amount of data (say, if you're Google), those two bytes can add up to a lot of bandwidth, especially since you're quite likely to repeat them multiple times in your stylesheet.

提交回复
热议问题