About the HTML and the BODY tag
<body> tags both come with some non-default behavior that you know from other tags.
Do not try to style
body for positioning, width/heigth, or similar. Every browser has its own caveats and you can not test them all.
- Use the
htmltag to define your page's default background color (because on short pages or large screens, your
bodymay not be as tall as the browser window).
- Use the
htmltag to define a base
font-sizeso you can use
remunits in CSS.
- Use either
bodytag to define
- Use a
bodyfor anything else (width, positioning, you name it).
Some extra information:
- The body element is (by default)
position:static, which means that positioned children of it are positioned relative to the html element's coordinate system.
- In almost all modern browsers, the built-in offset from the edge of the page is applied through a margin on the body element, not padding on the html element.
- Events triggered on an element bubble up to
html, then the
documenthas no visual representation on the page.
- There is a way to stretch a page to full window height