tags:

views:

37

answers:

4

if for a class i include "background:#252", the browser will assume the rest of the background properties that i didn't specify. If instead I used "background-color:#252", would it cause the browser to assume the exact same about the rest of the background properties that i leave unspecified?

background:#252 is shorter, but i wonder if it would be better to use background-color:#252? thanks.

+5  A: 

It would be better to use background-color and specify the full, 6-digit hex value IMO. All that silly shortening makes the code much harder to maintain, and invites mistakes, for zero gain.

Pekka
+1 for specifying full values! i had thought i was the only person left that did this
espais
@Pekka What about the extra 24 bits of bandwidth?
orokusaki
@orokusaki activate `mod_gzip` :D
Pekka
+1  A: 

The browser should interpret background: #252; as background-color: #252. Per W3C's website, using the first method is shorthand. The other values that are not specified will remain defaulted.

Of course, doing this may make it harder to maintain for future developers (including yourself). That is something you may want to consider.

JasCav
A: 

background: is a shorthand for when you want multiple properties, like so:

 {background:#ffffff url('img_tree.png') no-repeat top right;}

so it should work the same.

GSto
A: 

As previously mentioned, "background: #252" is merely shorthand for setting all the background properties. Yet in this case you have only specified the color, so it is equivalent to "background-color: #252".

If your only objective is to modify the background color with no intention of specifying the other values, it would probably be better to stick with "background-color:...".

Specifiying a six-digit hex value would be nice too (instead of only three numbers #252) to avoid any confusion to what color you are actually specifying.

Wagne499