CSS Size Ads

When sizing in margin / padding etc. in CSS, I often skip 'px' for a value of '0', for example.

.myClass { 5px 0 0 5px } 

Someone I’m working with recently told me to enable 'px'

 .myClass { 5px 0px 0px 5px } 

Are there any advantages or disadvantages or any approach? or is it just a preference?

+4
source share
2 answers

There are no flaws, you can use 0 without "px".

Zero length can be represented instead of "0". (In other words, for zero length, the device identifier is optional.)

http://www.w3.org/TR/css3-values/#lengths

Edit: This question has already been asked.

+5
source

Here is a brief overview of units in css, very useful as I think:

css units (w3c)

in general, it is useful to declare which device you are using, and 0 is always the same, so you do not need to write the device if you have a 0-value (zero), and there is no advantage if you do this write a block

(on the contrary, your css file is 2 bytes larger for each unregistered device that you write if it is not optimized: D)

0
source

All Articles