Open In App
Related Articles

HTML <body> Tag

Improve Article
Improve
Save Article
Save
Like Article
Like

 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 <html> tag. A body tag contains starting as well as an ending tag.
 

Syntax: 

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

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

  • 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 : Using HTML body tag. All then content placed inside the body tag.

HTML




<!DOCTYPE html>
<html>
 
<!-- 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: Example to show the functioning of a Body tag along with its CSS implementation.

HTML




<!DOCTYPE html>
<html>
 
<!-- 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: 
 

Supported Browsers: 

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer
  • Firefox 1 and above
  • Opera
  • Safari

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 20 Jul, 2022
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials