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

HTML How to Make a Website Customizing Colors and Fonts Use Classes in CSS

fareez idzuan
fareez idzuan
1,840 Points

What is difference between background and background-color? Is it same?

During the class Nick had teach, some error I've put in the main.css like

body { background: #999; } The grey color itself didn't appear.

When I follow the instruction by Nick, changed back the property of background to background-color, the color itself appeared.

Why happened like that? Kindly explain.

2 Answers

Fareez,

The background-color property sets a color in the background of an element.

The background property is a shorthand way to set multiple background-related properties all at once, all of which are optional: color, image(s), positioning, sizing, repeat, and other background properties (click the link for a full list).

You can simply use background: #999; and it should apply a gray background to the element.

Hello fareez idzuan in css body{background: black;} body{background-color: black;} there is no difference in the result, background actually is a shortcut.