Open In App

HTML body Tag

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The <body> tag in HTML defines the main content of a web page and is always placed within the <html> tag as its last child. It contains everything that is visible on the page, including headings,paragraphs,images,links, tables, and lists.

  • The <body> tag is required in every HTML document.
  • If omitted, most browsers will still render the content as if the tag were present, but it’s not considered good practice.

Syntax

<body> Body Contents... </body>

HTML Body Structure

index.html
<!DOCTYPE html>
<html lang="en">
<body>
    <h3>GeeksforGeeks</h3>
    <p>This is paragraph text</p>
</body>
</html>

Output

output
output

Attributes

There are many attributes in the <body> tag that are depreciated from HTML5 are listed below: 

Attribute Values

Description

background

It contains the URL of the background image. It is used to set the background image.

bgcolor

It is used to specify the background color of an image.

alink

It is used to specify the color of the active link.

link

It is used to specify the color of visited links.

text

It specifies the color of the text in a document.

vlink

It specifies the color of visited links.

Body tag with CSS implementation

index.html
<!DOCTYPE html>
<html lang="en">
<body style="background-color:seagreen">
    <h3>HTML body Tag</h3>
    <p>
        This is paragraph Tag and it's background-color is seagreen.
    </p>
</body>
</html>

Output

output
output

HTML <body> Tag Example with Hyperlink

index.html
<!DOCTYPE html>
<html>
<head>
<title>HTML LINKS</title>
</head>
<body>
<h2>Welcome To GFG</h2>
<a href="https://www.geeksforgeeks.org/community/">GFG Community</a>
</body>
</html>

Output

output
output

HTML <body> Tag with Text Color Attribute

index.html
<!DOCTYPE html>
<html>
<head>
<title>GFG color</title>
</head>
<body text="green">
<h2>Welcome To GFG</h2>
<p>Body Text color changed to green.</p>
</body>
</html>

Output

output
output

Browser Support



Similar Reads