Should we be applying CSS to <body> vs. <html> elements?


Possible Duplicate:
Should global css styles be set on the html element or the body element?

There's some really interesting discussion about applying CSS to <html> and <body> in order to get some cool effects — like two background images, one transparent (but CSS3 may render that useless).

However, for the standard cases, which element is most appropriate to use for appling page-wide CSS to?

Perhaps there's even some CSS properties that are better suited to one selector over the other? Thus, split among the two?

(This concerns things like cross-browser compatibility, as well as proper semantics according to spec.)

And we can also bring the wildcard * { } selector into this discussion.

Problem courtesy of: Baumr


I believe that the W3C recommends that you apply any page-wide styles to the <body> element.

Solution courtesy of: Jules


Following Verandaguy's answer, applies the style to the body. It doesn't say why, but, that's what it says.

Discussion courtesy of: ChrisW

For creating a site with several pages it is best to use the CSS as an external linked page. That way each page can have access to it. But for a single page to page, it would be a "cool effect" on some browsers. But in the same effect other computers might see those effects in a different and less rendered method. Stick with uses the CSS mostly as an external link, and use style tags only as needed, or leave a note on the page of how and what browser they are supposed to view it on.

Discussion courtesy of: mr.j05hua

This recipe can be found in it's original form on Stack Over Flow.