HTML <body> tag

HTML <body> tag defines the main content of an HTML document which displays on the browser. It can contain text content, paragraphs, headings, images, tables, links, videos, etc.

The <body> must be the second element after the <head> tag or it should be placed between </head> and </html> tags. This tag is required for every HTML document and should only use once in the whole HTML document.

Syntax

Following are some specifications about the <body> tag

DisplayInline
Start tag/End tagBoth start and End tag
UsageStructural

Example

Test it Now

Output:

HTML body tag

Attribute

Tag specific Attributes

AttributeValueDescription
alinkcolorIt defines the color of the active link in a document. (Not supported in HTML5)
backgroundURLIt determines the background image for the document. (Not supported in HTML5)
bgcolorcolorIt determines the background color of the content. (Not supported in HTML5)
linkcolorIt determines the color of the unvisited link. (Not supported in HTML5)
textcolorIt determines the color of the text in the document. (Not supported in HTML5)
vlinkcolorIt determines the color of the visited link. (Not supported in HTML5)
onloadFunction call on page loading
onunloadFunction call when user leaves the page
onfocusFunction call when document receives focus by user.
onblurFunction call when document loses focus by user.

Global Attribute

The <body> attribute supports global attribute in HTML.

Event Attribute

The <body> attribute supports Event attributes in HTML.

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<body>YesYesYesYesYes
Next TopicHTML br Tag




Latest Courses