I don’t see the difference between:
html {
background: #f1f1f1;
}
and
body {
background: #f1f1f1;
}
Any explanation?
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.
There is no real difference (if you’re just talking about where to apply
background, otherwise BoltClock’s answer to this other question is a better fit).htmlis an element, just likebodyis.Both are valid choices, and both will both work in all common browsers.
The YUI Reset for instance, chooses to set a
backgroundon thehtmlelement instead ofbody:http://yui.yahooapis.com/3.3.0/build/cssreset/reset.css
This requires that you set your
backgroundonhtml, for instance see: can't change body background color using CSS resetSee: http://dev.w3.org/csswg/css3-background/#special-backgrounds
And:
What that wall of text is saying is demonstrated here:
backgroundon justbody: http://jsfiddle.net/hhtzE/backgroundonhtmlandbody: http://jsfiddle.net/hhtzE/1/backgroundonlyhtml: http://jsfiddle.net/hhtzE/2/