What’s the difference between specifying a background color using background and background-color?
Snippet #1
body { background-color: blue; }
Snippet #2
body { background: blue; }
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Premising that those are two distinct properties, in your specific example there’s no difference in the result, since
backgroundactually is a shorthand forThus, besides the
background-color, using thebackgroundshorthand you could also add one or more values without repeating any otherbackground-*property more than once.Which one to choose is essentially up to you, but it could also depend on specific conditions of your style declarations (e.g if you need to override just the
background-colorwhen inheriting other relatedbackground-*properties from a parent element, or if you need to remove all the values except thebackground-color).