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 trialJeizebel Espiritu
2,525 Pointswhy do we use background-image property if background property can also be use to set color or image ?
why do we use background-image property if background property can also be use to set color or image ?
2 Answers
Bryan Knight
34,215 PointsJeizebel,
background is a shorthand property that can be used to modify all of the following:
background-color
background-image
background-position
background-repeat
background-attachment
background-clip
background-origin
background-size
You'll get the same results from using both, but you can use the singular property background-image in the instance where you are inheriting background properties from a cascade and you want to keep all of the background properties except for the background image. You can then just overwrite the inherited background image using the background-image property on the new element and keep all of the other inherited properties.
Does that make sense?
Guled Ahmed
12,806 PointsFound a great answer to that question here.
Moderator changed this from a "Comment" to an "Answer," so it may be voted on and/or marked as best answer.