The <body> represents the content of an HTML document. There can be only one <body> element in a document.
| Content categories | Sectioning root. |
|---|---|
| Permitted content | Flow content. |
| Tag omission | The start tag may be omitted if the first thing inside it is not a space character, comment, <script> element or <style> element. The end tag may be omitted if the body element has contents or has a start tag, and is not immediately followed by a comment. |
| Permitted parents | It must be the second element of an <html> element. |
| Permitted ARIA roles | None |
| DOM interface |
HTMLBodyElement
|
This element includes the global attributes.
alink
color property in conjunction with the :active pseudo-class instead.
background
background property on the element instead.
bgcolor
background-color property on the element instead.
bottommargin
margin-bottom property on the element instead.
leftmargin
margin-left property on the element instead.
link
color property in conjunction with the :link pseudo-class instead.
onafterprintonbeforeprintonbeforeunloadonbluronerroronfocusonhashchange'#') character) of the document's current address has changed.onlanguagechange
onloadonmessageonofflineononlineonpopstateonredoonresizeonstorageonundoonunloadrightmargin
margin-right property on the element instead.
text
color property on the element instead.
topmargin
margin-top property on the element instead.
vlink
color property in conjunction with the :visited pseudo-class instead.
<html>
<head>
<title>Document title</title>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
| Specification | Status | Comment |
|---|---|---|
| HTML Living Standard The definition of '<body>' in that specification. | Living Standard | Changed the list of non-conforming features. |
| HTML5 The definition of '<body>' in that specification. | Recommendation | Obsoleted the formerly deprecated attributes. Defined the behavior of the non-conforming and never standardized margintop, marginleft, marginright and marginbottom. Added the on* attributes. |
| HTML 4.01 Specification The definition of '<body>' in that specification. | Recommendation | Deprecated the alink, background, bgcolor, link, text and vlink attributes. |
| Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 1 | 12 | 1 | Yes | Yes | Yes |
alink |
1 | 12 | 1 | Yes | Yes | Yes |
background |
1 | 12 | 1 | Yes | Yes | Yes |
bgcolor |
1 | 12 | 1 | Yes | Yes | Yes |
bottommargin |
Yes | No | 351 | No | Yes | ? |
leftmargin |
Yes | No | 351 | No | Yes | ? |
link |
1 | 12 | 1 | Yes | Yes | Yes |
onafterprint |
1 | 12 | 1 | Yes | Yes | Yes |
onbeforeprint |
1 | 12 | 1 | Yes | Yes | Yes |
onbeforeunload |
1 | 12 | 1 | Yes | Yes | Yes |
onblur |
1 | 12 | 1 | Yes | Yes | Yes |
onerror |
1 | 12 | 1 | Yes | Yes | Yes |
onfocus |
1 | 12 | 1 | Yes | Yes | Yes |
onhashchange |
1 | 12 | 1 | Yes | Yes | Yes |
onlanguagechange |
? | No | 32 | No | ? | ? |
onload |
1 | 12 | 1 | Yes | Yes | Yes |
onmessage |
1 | 12 | 1 | Yes | Yes | Yes |
onoffline |
1 | 12 | 1 | Yes | Yes | Yes |
ononline |
1 | 12 | 1 | Yes | Yes | Yes |
onpopstate |
1 | 12 | 1 | Yes | Yes | Yes |
onredo |
1 | 12 | 1 | Yes | Yes | Yes |
onresize |
1 | 12 | 1 | Yes | Yes | Yes |
onstorage |
1 | 12 | 1 | Yes | Yes | Yes |
onundo |
1 | 12 | 1 | Yes | Yes | Yes |
onunload |
1 | 12 | 1 | Yes | Yes | Yes |
rightmargin |
Yes | No | 351 | No | Yes | ? |
text |
1 | 12 | 1 | Yes | Yes | Yes |
topmargin |
Yes | No | 351 | No | Yes | ? |
vlink |
1 | 12 | 1 | Yes | Yes | Yes |
| Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
|---|---|---|---|---|---|---|---|
| Basic support | Yes | 1 | 12 | 4 | Yes | Yes | Yes |
alink |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
background |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
bgcolor |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
bottommargin |
Yes | Yes | No | 351 | No | Yes | ? |
leftmargin |
Yes | Yes | No | 351 | No | Yes | ? |
link |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onafterprint |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onbeforeprint |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onbeforeunload |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onblur |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onerror |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onfocus |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onhashchange |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onlanguagechange |
? | ? | No | 32 | No | ? | ? |
onload |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onmessage |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onoffline |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
ononline |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onpopstate |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onredo |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onresize |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onstorage |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onundo |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
onunload |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
rightmargin |
Yes | Yes | No | 351 | No | Yes | ? |
text |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
topmargin |
Yes | Yes | No | 351 | No | Yes | ? |
vlink |
Yes | 1 | 12 | 4 | Yes | Yes | Yes |
1. Before Firefox 35, it was supported in Quirks Mode only.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body