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 How to Make a Website Responsive Web Design and Testing Adding Breakpoints for Devices

Hadi Farhat
PLUS
Hadi Farhat
Courses Plus Student 7,102 Points

Why did Nick Pettit use background for colors instead of background-color

We usually use background-color for the color of the background, is there a difference between background-color and background ?

3 Answers

Diego Murray
Diego Murray
2,515 Points

There's no exact difference. Background is a shortcut. For example, You can list items such as background-color: blue; background-position: center; background-repeat: none;

Using the background property you can put all of those in one line of code.

Jeff Lemay
Jeff Lemay
14,268 Points

background-color accepts a color only, while background is shorthand for using background color, background image, background repeat, background position, etc.

You can use background in place of background-color and achieve the same result.

The background property can take a list of several arguments, including color, just like border can take several elements (black solid 2px).

Background-color is just more specific.