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
  • 700,868
  • 160
  • 1,392
  • 1,356
Web_Designer
  • 72,308
  • 93
  • 206
  • 262
  • 2
    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
  • 2
    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,746
  • 28
  • 47
  • 65
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
  • 320,036
  • 81
  • 464
  • 592