Table of contents

HTML <body> Tag

What is HTML <body> Tag?

The HTML body tag defines the main content area of a webpage that is visible to users. Everything inside the body tag, such as text, images, links, tables, lists, and other HTML elements appears on the browser screen. It is one of the most essential HTML tags because it represents the main portion of any web page. The content inside the body tag is what users actually see and interact with, unlike the head section, which contains meta information.

Every HTML document must have one body tag, and it always comes after the head tag.

Syntax of the HTML <body> Tag

plaintext
<body>
  Page Content Goes Here
</body>

The body tag starts with <body> and ends with </body>. All the visible content such as headings, paragraphs, images, and links should be placed between these tags.

Examples of HTML <body> Tag

Example 1: Basic HTML Body Tag

plaintext
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Welcome to Scholar247</title>
</head>

<body>
  <h1>Hello, World!</h1>
  <p>Welcome to Scholar247, your trusted learning platform.</p>
</body>
</html>

In this example, everything written between the body tags is displayed in the browser window. The heading and paragraph are visible to the user.

Example 2: SEO Optimized HTML Body Tag

plaintext
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Best HTML Tutorials for Beginners | Scholar247</title>
</head>

<body>
  <header>
    <h1>Learn HTML Step by Step</h1>
  </header>

  <section>
    <p>At Scholar247, we provide high-quality, beginner-friendly HTML tutorials to help you build web pages with confidence.</p>
  </section>

  <footer>
    <p>Copyright © 2025 Scholar247</p>
  </footer>
</body>
</html>

This example includes an SEO-optimized title and well-structured HTML body content. Each section (header, section, footer) helps organize the webpage, improving both readability and search performance.

Attributes of the HTML <body> Tag

The body tag supports several attributes, though most are replaced by CSS in modern HTML. Some of the commonly used attributes include:

background – Sets a background image for the page.
bgcolor – Defines the background color of the page.
text – Changes the color of the text on the page.
link – Defines the color of hyperlinks.
vlink – Sets the color of visited links.
alink – Specifies the color of active links.

Even though these attributes still work, it is recommended to use CSS for styling instead of inline attributes to ensure better design and SEO practices.

Best Practices for HTML <body> Tag

• Always include only one body tag per page.
• Keep your body tag content structured using semantic HTML elements such as header, main, and footer.
• Use external CSS for styling instead of deprecated attributes like bgcolor or background.
• Keep the HTML inside the body tag well-organized for readability and SEO.
• Always close the body tag properly before closing the html tag.

FAQs About the HTML <body> Tag

Q1: What is the purpose of the HTML body tag?

The HTML body tag defines the visible content of a webpage. Everything displayed in the browser, such as text, images, and links, is placed inside the body tag.

Q2: Can a webpage have more than one body tag?

No. Each HTML document must contain only one body tag. Having multiple body tags can break the structure and cause rendering issues in browsers.

Q3: Is the body tag required in HTML?

Yes. The body tag is required in every HTML document because it holds all the visible content of the webpage.

Q4: What comes before and after the body tag?

The body tag comes after the head tag and before the closing html tag.

Q5: Can I style the body tag directly?

Yes. You can use CSS to style the body tag. For example, you can set background color, font, or margins to affect the entire webpage.

HTML

Related Articles