- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <body> Tag
HTML Tags
HTML <body> Tag
The body tag holds everything people actually see on the page: headings, text, images, links, forms. Everything that is not information about the page goes inside body, after the head.
Every page has one <head> for information about the page, like its title, and one <body> for its content. Both sit inside the html tag.
Syntax
html
<body>
<!-- Visible content goes here -->
</body>Example
html
<!DOCTYPE html>
<html>
<head>
<title>Body Tag Example</title>
</head>
<body>
<h1>Welcome to My Webpage</h1>
<p>This content is inside the body tag.</p>
<img src="https://picsum.photos/seed/picsum/400/300" alt="Sample Image" width="400">
</body>
</html>The heading and paragraph appear on the page because they are inside <body>. The <title> in the head appears only in the browser tab.
Good to know
- One
<body>per page, directly after</head>. - Old attributes like
bgcolor,textandbackgroundon body are obsolete. Style the page with CSS onbodyinstead, for examplebody { margin: 0; font-family: system-ui, sans-serif; }. - Browsers add a default margin of 8px around the body. That is why many stylesheets start with
body { margin: 0; }. - Scripts are often placed just before
</body>, so the page content loads first. With thedeferattribute, they can go in the head instead; see the script tag.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
HTML <body> Tag exercises
Put content on the page
Write a page with the title Home. In the body put a level 1 heading, Welcome, and the paragraph Everything you see is here.
Result
Check your answer to see it here.
