Tag body

The <body> tag defines the main content area of an HTML document — everything inside <body> is what you see on the webpage.

It sits below the <head> tag and wraps all visible elements like:

  • Text (<p><h1>, etc.)
  • Images (<img>)
  • Links (<a>)
  • Lists (<ul><ol>)
  • Forms (<form>)
  • Videos, audios, scripts, etc.

✅ Syntax

<!DOCTYPE html>
<html lang="en">
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello, world!</h1>
<p>This is a paragraph inside the body.</p>
</body>
</html>

📌 Everything rendered on the screen is written inside the <body> tag.


🧩 Typical Structure

<html>
<head>
<!-- Metadata, CSS, title, etc. -->
</head>
<body>
<!-- Visible content goes here -->
</body>
</html>

🎨 Styling the <body>

You can apply CSS directly to the <body> tag to style the whole page:

<style>
body {
background-color: #f0f0f0;
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
</style>

🧠 Best Practices

  • Only one <body> per page.
  • Keep it clean and organized using sections (<header><main><footer>, etc.).
  • Load scripts at the end of the <body> (or use defer in <head>) for better performance.

✅ Summary

TagPurpose
<body>Contains all visible HTML content
LocationInside <html>, after <head>
ContentText, images, videos, forms, links

Would you like an example of a fully structured page using the <body> tag, or help building a basic layout (header, main, footer)? Just let me know!