HTML Tags

HTML <body> Tag

The <body> tag contains all the visible content of an HTML page, including text, images, links, tables, and more.


What is the <body> tag?

The <body> element represents the content of an HTML document. Everything the user sees in the browser window lives inside <body>. There is exactly one <body> per document, and it comes right after the <head>, as the second child of <html>.

Syntax

<body>
  <!-- visible content goes here -->
</body>

Complete example

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Body Tag Demo</title>
  </head>
  <body>
    <h1>Welcome</h1>
    <p>This paragraph is visible because it lives inside the body.</p>
    <a href="https://myinternships.in">Visit MyInternships.in</a>
  </body>
</html>

Attributes

The <body> element supports the global attributes plus several event-handler attributes that fire on window-level events:

AttributeDescription
onloadRuns a script after the page has finished loading.
onunloadRuns a script when the user leaves the page.
onresizeRuns a script when the browser window is resized.
onscrollRuns a script when the document is scrolled.
⚠️

Presentational attributes like bgcolor, background, text, and link are deprecated. Use CSS (for example the background-color property) to style the body instead.

The <body> tag is supported in all browsers and is a block-level container by default.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships