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
Pedro Lopes
4,281 PointsWhat is the difference between background | background-color?
For example:
body{background-color:orange;}
or
body{background:orange;}
3 Answers
David Bloomfield
11,622 PointsAs Jonathan and Stuart said, one is a specific property and the other is used for CSS shorthand.
E.g.
background-color: orange;
background-image: url('images/yourimage.png');
background-position: 0 50%;
background-repeat: no-repeat;
Can be written
background: orange url('images/yourimage.png') 0 0 no-repeat;
Thanks David
Jonathan Rhodes
8,086 Pointsbackground-color is a specific property in the wider property of background. With background, you are not limited to just colors, you can also place images and linear-gradients together, as well as specify positioning. Basically it's a shorthand for declaring all aspects of the background.
Stuart Wright
41,120 PointsYou will likely learn more about the difference in future Treehouse courses, but the background property can be used as shorthand to set several different properties relating to the background in one line of code. For example, you can use the background property to set an image, the position of the background image, and whether or not it repeats. The background-color property sets exactly one property, the background color.