Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is {background:0;} valid CSS?

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;}
like image 641
user1794295 Avatar asked Jun 19 '14 12:06

user1794295


People also ask

Is background None valid?

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.

What is CSS background-size?

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.

What does background None mean?

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).

Can we specify the background-size in percentage in CSS?

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.


2 Answers

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;
like image 77
griffon vulture Avatar answered Oct 27 '22 03:10

griffon vulture


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;
like image 3
Guffa Avatar answered Oct 27 '22 02:10

Guffa