Body Tag in HTML 5

The body tag helps render content on browser. This is main and necessary tag of HTML5, without this tag you can’t do anything on your HTML5 document.
  • 2118
 

This is main and necessary tag of HTML5, without this tag you can't do anything on your HTML5 document. The body tag must be placed after the end of the head element inside the html element. Body tag is used for define the content body of document. The body tag helps render content on 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:

<!
DOCTYPE html>
<
html>
  <head>
      <title>&lt;Example of Body tag&gt;</title>
  </head>
   <body style="background-color:Gray" >
   <p style="width:700px; height:100px; background-color:Silver; font-size:60px; color:White; font-weight:bold; text-align:center"> This is content page.
   </p>         
  </body>

</
html>

 



<!
DOCTYPE html>
<
html>
  <head>
      <title>&lt;Example of Body tag&gt;</title>
  </head>
   <body style="background-color:Gray" >
   <p style="width:700px; height:100px; background-color:Silver; font-size:60px; color:White; font-weight:bold; text-align:center"> This is content page.
   </p>         
  </body>

</
html>

Output

Internet Explorer

1.gif

Chrome

2.gif

Fire Fox

3.gif

Safari

  4.gif

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.