0

I am wondering if in the following context should I use 0px or 0.

box-shadow:inset 0px 15px 10px -15px #000

or

box-shadow:inset 0 15px 10px -15px #000
Lorraine Bernard
  • 13,000
  • 23
  • 82
  • 134

3 Answers3

3

When using 0 it's almost always appropriate to use it on its own.

The reason for specifying the measurement type is to make it clear how many of what measurement you expect. In the case of 0 it doesn't matter what the measurement type is (in this context) since 0 elephants is the same as 0px.

Jamie Dixon
  • 53,019
  • 19
  • 125
  • 162
1

It doesn't make any difference. 0 is 0px is 0em is 0%. It's a special case where you don't need units. Semantically it's up to you

There are two tiny provisors: first, if you use 0px then during development when you are using web inspector or firebug you can change the values by pressing the up and down arrows. If you use 0 then it doesn't know what units to use and that trick won't work. Second, if you use 0 instead of 0px, you save 2 characters, which is like the worlds littlest file size optimisation. But it's not exactly worth much.

moopet
  • 6,014
  • 1
  • 29
  • 36
0

They both work, so it's pretty much personal preference.

0 is special in that it means 0 of any unit presented but I usually declare the unit of measurement for ease of reading.

http://jsfiddle.net/Kyle_Sevenoaks/UFgpt/

Kyle
  • 65,599
  • 28
  • 144
  • 152