Open In App
Related Articles

HTML <body> Tag

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The <body> tag in HTML is used to define the main content present inside an HTML page. It is always enclosed within <HTML> tag. The <body> tag is the last child of the <html> tag. The <body> tag contains all the contents of an HTML document, such as headings, images, hyperlinks, tables, lists, paragraphs, etc.

Syntax: 

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

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.

Example 1: In this example we will use HTML body tag in which all content placed inside the body tag.

HTML

<!DOCTYPE html>
<html lang="en">
 
<head>
    <title>Document</title>
</head>
<!-- body tag starts here -->
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2>body Tag</h2>
    <p>This is paragraph text</p>
</body>
 
<!-- body tag ends here -->
 
</html>

                    

Output: 


Example 2: In this example we will show the functioning of a Body tag along with its CSS implementation.

HTML

<!DOCTYPE html>
<html lang="en">
 
<head>
    <title>Document</title>
</head>
 
<!-- style on the body tag -->
<!-- body tag starts here -->
 
<body style="background-color:seagreen">
    <h1>GeeksforGeeks</h1>
    <h2>HTML body Tag</h2>
    <p>
        This is paragraph Tag
    </p>
</body>
 
<!-- body tag ends here -->
 
</html>

                    

Output: sou


Supported Browsers: 

  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 15
  • Safari 1


Last Updated : 29 Dec, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads