Is {background:0;} valid CSS?
Asked Answered
T

2

6

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;}
Truculent answered 19/6, 2014 at 12:35 Comment(3)
developer.mozilla.org/en-US/docs/Web/CSS/background it will work but I never seen anyone use it like thatParthenia
It is background: none not background:0Jannajannel
@kougiland: No, that means something different, i.e. background-image: none instead of background-position: 0Sextuplet
D
8

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;
Diphosgene answered 19/6, 2014 at 12:36 Comment(0)
S
3

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;
Sextuplet answered 19/6, 2014 at 12:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.