tags:

views:

98

answers:

3
background:#777777 none repeat scroll 0 0;

the 5 attributes it includes are background-color,background-image,background-repeat,background-attachment and background-position.

My question is:

Are background-repeat,background-attachment and background-position useless if background-image is none? Because according to the document,these are all used to change background-image.

+2  A: 

yes. They have no meaning without that.

Zack
So it's a waste of code,right?The same as background:#777777 none?
Shore
yes. If you just want to set the background color, you can just do background-color: #777777;
Zack
+1  A: 

You can simply write

background:#777777;

or,

background-color:#777777;

All of those attributes affect the image only.

In general, if a CSS attribute sets multiple values (eg, background, border, font), you don't need to specify all of the values; any values you don't specify will be left at their defaults.

SLaks
oh,background:#777777;this version is more compact than background:#777777 none
Shore
Exactly .
SLaks
A: 

IF you just want a background color, consider using the background-color attribute instead of background.

PatrikAkerstrand
Though keep in mind, background-color will not override a background-image set elsewhere...
Shog9