HTML <body> element specifies the primary content of an HTML page that appears in a web browser. This section can include text, paragraphs, headings, images, tables, hyperlinks, videos, and more.
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
Example
<body> Place your Content here........</body>
Here are specific details regarding the <body> element:
| Display | Inline |
|---|---|
| Start tag/End tag | Both start and End tag |
| Usage | Structural |
Example
Example
<!DOCTYPE html>
<html>
<head>
<title>Body Tag</title>
</head>
<body>
<h2>Example of body tag</h2>
<p>This paragraph is written between the body tag</p>
</body>
</html>
Output:
Attribute
Tag specific Attributes
| Attribute | Value | Description |
|---|---|---|
| alink | color | It defines the color of the active link in a document. (Not supported in HTML5) |
| background | URL | It determines the background image for the document. (Not supported in HTML5) |
| bgcolor | color | It determines the background color of the content. (Not supported in HTML5) |
link |
color | It determines the color of the unvisited link. (Not supported in HTML5) |
text |
color | It determines the color of the text in the document. (Not supported in HTML5) |
| vlink | color | It determines the color of the visited link. (Not supported in HTML5) |
| onload | Function call on page loading | |
| onunload | Function call when user leaves the page | |
| onfocus | Function call when document receives focus by user. | |
| onblur | Function call when document loses focus by user. |
Global Attribute
The <body> attribute facilitates the use of global attributes in HTML.
Event Attribute
The <body> attribute enables the integration of Event attributes within HTML.
Supporting Browsers
| Element | Chrome | IE | Firefox | Opera | Safari |
|---|---|---|---|---|---|
<body> |
Yes | Yes | Yes | Yes | Yes |