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: or background-color:.... Which is the correct way?

In CSS Deep Dive videos Guil sometimes types background: and sometimes background-color: to set the color of background of an element. My question is which is the correct and appropriate way? Or are both valid?

1 Answer

Hey Omer,

There's no real difference since background is a shortcut for:

  1. background-color
  2. background-image
  3. background-position
  4. background-repeat
  5. background-attachment

If you use the background shortcut you could add the properties 2-5 without repeating background-image, background-position... and so on.

I hope this helps.

Thanks