Body Tag Used to Define Content in Document in HTML5

Introduction 

 
This is a main and necessary tag of HTML5, without this tag you can't do anything in your HTML5 document. The body tag must be placed after the end of the head element inside the HTML element. The body tag is used for defining the body content of a document. The body tag helps render content in a browser. The body tag contains all the contents of an HTML document, such as HTML comment, button, text, paragraph, lists, image, audio, video, hyperlink, etc.
 
Syntax
 
<body
alink="color name | #RRGGBB"
background="URL of background image"
bgcolor="color name | #RRGGBB"
class="class name(s)"
dir="ltr | rtl"
id="unique alphanumeric identifier"
lang="language code"
link="color name | #RRGGBB"
style="style information"
text="color name | #RRGGBB"
title="advisory text"
vlink="color name | #RRGGBB">
</body>
 
Example
 
Attributes Introduced by HTML5
accesskey spaced list of accelerator key(s)
contenteditable true | false | inherit
contextmenu id of menu
data-X user-defined data
draggable true | false | auto
hidden hidden
itemid microdata id in URL format
itemprop microdata value
itemref space-separated list of IDs that may contain microdata
itemscope itemscope
itemtype microdata type in URL format
spellcheck true | false
tabindex number
 
Attributes Defined by Internet Explorer
accesskey "key" (5.5)
bgproperties "fixed" (4)
bottommargin "pixels" (4)
contenteditable "false | true | inherit" (5.5)
disabled "false | true" (5.5)
hidefocus "true | false" (5.5)
language "javascript | jscript | vbs | vbscript" (4)
leftmargin "pixels" (4)
nowrap "false | true" (4)
rightmargin "pixels" (4)
scroll "no | yes" (4)
tabindex "number" (5.5)
topmargin "pixels" (4)
unselectable "off | on" (5.5)
 
Attributes Defined by Netscape
marginheight "pixels" (4)
marginwidth "pixels" (4)
 
HTML5 Event Attributes
onabort onafterprint onbeforeprint onbeforeunload
onblur oncanplay oncanplaythrough onchange
onclick oncontextmenu ondblclick ondrag
ondragend ondragenter ondragleave ondragover
ondragstart ondrop ondurationchange onemptied
onended onerror onformchange onforminput
oninput oninvalid onhashchange onkeydown
onkeypress onkeyup onload onloadeddata
onloadedmetadata onloadstart onmessage onmousedown
onmousemove onmouseout onmouseover onmouseup
onmousewheel onoffline ononline onpause
onplay onplaying onpopstate onprogress
onratechange onreadystatechange onredo onresize
onscroll onseeked onseeking onselect
onshow onstalled onstorage onsubmit
onsuspend ontimeupdate onundo onunload
onvolumechange onwaiting    
 
Events Defined by Internet Explorer
onactivate onafterprint onbeforeactivate onbeforecut
onbeforedeactivate onbeforeeditfocus onbeforepaste onbeforeprint
onbeforeunload oncontextmenu oncontrolselect oncut
ondeactivate ondrag ondragend ondragenter
ondragleave ondragover ondragstart ondrop
onfilterchange onfocusin onfocusout onlosecapture
onmouseenter onmouseleave onmousewheel onmove
onmoveend onmovestart onpaste onpropertychange
onreadystatechange onresizeend onresizestart onscroll
onselect onselectstart    
 
Code: 
  1. <!DOCTYPE html>  
  2. <html>  
  3.     <head>  
  4.         <title><Example of Body tag></title>  
  5.     </head>  
  6.     <body style="background-color:Gray" >  
  7.         <p style="width:700px; height:100px; background-color:Silver; font-size:60px; color:White; font-weight:bold; text-align:center"> This is content page.  
  8.    </p>  
  9.     </body>  
  10. </html>  
  11. <!DOCTYPE html>  
  12. <html>  
  13.     <head>  
  14.         <title><Example of Body tag></title>  
  15.     </head>  
  16.     <body style="background-color:Gray" >  
  17.         <p style="width:700px; height:100px; background-color:Silver; font-size:60px; color:White; font-weight:bold; text-align:center"> This is content page.  
  18.    </p>  
  19.     </body>  
  20. </html>  
Output 
 
Internet Explorer
 
Body tag
 
Chrome 
 
Body tag
 
FireFox 
 
Body tag
 
Safari 
 
Body tag