Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

background vs background-color

Could someone please explain me the difference between background and background-color.

5 Answers

Hi Bilal,

If all you're trying to do is set the background-color then there's no difference between the two as long as you have not previously set any other individual background properties.

When you use the shorthand background property, all omitted values will be reset back to their initial values.

For example, if you have this:

a {
    background-image: url('img/some_image.png');
    background: red;
}

You will lose that background image. I used the background shorthand property and I only specified a background-color. This means that since I've omitted a value for background-image then it will be set back to its initial value of none. All of the other individual property values that I've omitted will also be set back to their initial values.

Sometimes this might be what you want and other times not. So it's just something to be aware of and watch out for.

So that would be one difference and Daniel has pointed out the other difference. background-color is an individual property and background is the shorthand property for about a dozen individual properties where you can specify all or just some of the values.

Background color: only takes one argument, the color you want the background to be.

Background: takes several arguments, one of which can be the color.
Background also takes arguments for: background-color, background-image, background-repeat, background-position, etc.

make sense?

yes, so basically it Background color: red and Background: red would imply the same thing, right?

Thanks a lot Jason and Daniel for the help

Another question that I have is that the things is that I have just started at treehouse and I take down notes for each individual video. This makes it easy for me to remember the stuff but it makes it a really slow process. I feel that if I wont take down notes then most probably I will forget the stuff that I learned and thus would have to re-watch the videos. What would you recommend me to do and what is your approach to learning?

I personally don't take down notes during videos. I do code along with the videos though and I will pause somewhat frequently while I catch up. Sometimes I'll rewind a little bit if I feel I need to hear something again. Also, I will bookmark any links that the Teacher's give in the Teacher's Notes section so that I'll have them for future reference.

I think that if I've forgotten something and need to look it up I'll be able to find it faster searching on google than I will looking through my notes.

The more that you practice the more that you will commit the more common things to memory. There will be certain things that you will use frequently and they'll become second nature to you. Use google for the things that you don't use that often where you might have forgotten the syntax.

An important skill to have is not so much to memorize all this stuff but to know where to look when you've forgotten something.