<body>

Describes the visible content of an HTML page.
2 min read
Believemy logo

The <body> tag is an essential element in HTML. It contains all the visible content of a web page, such as buttons, images, and text elements.

The content placed within the <body> tag is then displayed by the browser to be visible and usable on the users' screens.

Good to know

It is always included after the <head> tag. 😉

 

Structure and syntax of the <body> tag

Basic structure and syntax

The <body> tag is a container: it is therefore used with:

  • an opening tag <body>;
  • and a closing tag </body>.

Here is how to use it (quite simple as you will see!):

HTML
<body>
  <!-- Your image, button, and text tags -->
</body>

 

Usage example

As it is always easier to get an idea with a complete example, here is one! ☝️

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example of body tag</title>
</head>
<body>
  <header>
    <h1>Welcome to my site</h1>
  </header>
  <main>
    <p>This is an example of content within the <strong>&lt;body&gt;</strong> tag.</p>
    <a href="https://believemy.com">Visit this link</a>
  </main>
  <footer>
    <p>Copyright © 2025</p>
  </footer>
</body>
</html>

As we can see here, only the elements within <body> are displayed on the users' screens. Try it yourself:

 

Attributes of the <body> tag

The <body> tag can include all "classic" attributes but it also contains two other specific ones.

AttributeDescription
onloadExecutes JavaScript after the page has loaded.
onunloadExecutes JavaScript just before leaving the page.

 

Browser compatibility

As you might expect, the <body> tag is compatible with all browsers!

At the same time, without it... There would be no "standardized" web page (that adheres to the standards of the W3C).

ElementGoogle ChromeSafariMozilla FirefoxEdge
<body>YesYesYesYes

Related terms

Discover our hTML and CSS glossary

Browse the terms and definitions most commonly used in HTML and CSS development.

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.