I understand that background
is the shorthand property - what will the value 0
do to all of the properties and is it valid CSS?
selector {background:0;}
CSS “background-color:none” is valid. But it is better to specify it as “transparent” instead of “none”. The CSS background-color property is used to specify the background color of an element. The background covers the total size of the element with padding and border but excluding margin.
The background-size CSS property sets the size of the element's background image. The image can be left to its natural size, stretched, or constrained to fit the available space.
when you set: background:none; you are saying that all the background properties are set to none... You are saying that background-image: none; and all the others to the initial state (as they are not being declared).
If you only provide one value (e.g. background-size: 400px ) it counts for the width, and the height is set to auto . You can use any CSS size units you like, including pixels, percentages, ems, viewport units, etc.
background:0
is valid css and gets compiled into:
background-image: initial;
background-position-x: 0px;
background-position-y: 50%;
background-size: initial;
background-repeat-x: initial;
background-repeat-y: initial;
background-attachment: initial;
background-origin: initial;
background-clip: initial;
background-color: initial;
Yes, the zero will be interpreted as the horizontal background position. The other background properties are set to the default values, so you end up with the same as:
background-image: none;
background-repeat: repeat;
background-attachment: scroll;
background-position: 0 center;
background-color: transparent;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With