0

I have seen two notations:

padding: 0px

and just

padding: 0

I would like to know which is the correct way or syntactically correct way.

I have seen both ways in different places:

  • 1
    Does this answer your question? ['property: 0' or 'property: 0px' in CSS?](https://stackoverflow.com/questions/4318471/property-0-or-property-0px-in-css) – Naveen Setty Oct 07 '21 at 22:29
  • 1
    always use `0px` and you will thank me one day (related: https://stackoverflow.com/q/62520998/8620333) – Temani Afif Oct 07 '21 at 22:33

1 Answers1

1

Both are syntactically correct and correct in general. When you have 0 of anything, it is still 0, so in terms of value, 0 is the same as 0px which is the same as 0[AnyMeasurementHere]. If you wanted to update the style later, and you were using pixels, you might keep it at 0px to remind yourself that you are using pixels on this element for its padding.

Marcus Parsons
  • 1,714
  • 13
  • 19