4

What are the advantages & disadvantages of styling the <html> element instead of the <body> element?

I have seen it used in many cases such as in a full page background image, or to make an element take up 100% of the view port height.

...but I'm sure there are some limitations. Do you know of any specific browser support issues etc?

BoltClock
  • 665,005
  • 155
  • 1,345
  • 1,328
Web_Designer
  • 68,768
  • 89
  • 200
  • 259
  • 1
    Here's another use: [Sizing fonts with REM units](http://snook.ca/archives/html_and_css/font-size-with-rem) – Web_Designer Jan 22 '12 at 02:25
  • 1
    see [What's the difference between applying CSS to html, body, and *?](http://stackoverflow.com/questions/7187569/whats-the-difference-between-applying-css-to-html-body-and) and [Should global css styles be set on the html element or the body element?](http://stackoverflow.com/questions/4565942/should-global-css-styles-be-set-on-the-html-element-or-the-body-element) - the latter seems to be a closer dupe – BoltClock Jan 24 '12 at 14:06

2 Answers2

1

Here are two articles about this very thing:
How to center and layout pages without a wrapper
Styling HTML and body elements

Rob
  • 14,107
  • 28
  • 46
  • 64
0

An example of this is for a fixed-width body. I use this on my own site - the light green area is the body and the gradient background is applied to the html element.

As far as I am aware there are no browser issues. Maybe in IE5.5 (because I do see problems in Quirks Mode) but aside from that it works just fine.

Niet the Dark Absol
  • 311,322
  • 76
  • 447
  • 566