# What is HTML body and how to use it

The HTML `<body>` element contains all the visible content of an HTML document. There can only be one `<body>` area per HTML document.

## What is the HTML `<body>` tag and what is it used for?

HTML `<body>` is an [HTML](https://www.ionos.com/digitalguide/websites/web-development/what-is-html/) element that is used to display the content of a document to users. All **visible content** such as headlines, text blocks, images, tables, hyperlinks, lists and other elements are stored within this [HTML tag](https://www.ionos.com/digitalguide/websites/web-development/html-tags/). There can only be **one HTML `<body>`** in each document. This is always located below the `<head>` area and above the HTML footer. The `<body>` tag supports all global [HTML attributes](https://www.ionos.com/digitalguide/websites/web-development/html-attributes/).

## What is the syntax and functionality of HTML `<body>`?

Before we show you how HTML `<body>` works using a few simple examples, it’s worth taking a look at the basic syntax of the element. This looks as follows:

```html
<body>This is where all the visible website content is stored.<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>
```

Only content between the introductory (`<body>`) and closing (`<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>`) tags will be displayed later on the relevant web page.

## HTML `<body>` examples

In the following examples, you can see how the HTML `<body>` tag is used in practice.

### HTML document with simple `<body>` element

First, we’re going to create a simple HTML document with a **headline, a text section and an image**, all of which are placed within the body. This is the corresponding code:

```html
<html>
<head>
<title>HTML body in a document</title>
</head>
<body>
<h1>Here’s your heading</h1>
<p>Here’s your website content.</p>
<img src="example.jpg" alt="Here’s an image">
<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>
</html>
```

### Creating a navigation bar with href

The following example shows you how to create a navigation bar for your website using the HTML `<body>` tag and the [href](https://www.ionos.com/digitalguide/websites/web-development/a-href-html/) attribute. Here’s the code:

```html

<html>
<head>
<title>Website with a navigation bar</title>
</head>
<body>
<nav>
<a href="#home">Home</a> |
<a href="#about">About</a> |
<a href="#contact">Contact</a>
</nav>
<section id="home"><h2>Home</h2></section>
<section id="about"><h2>About</h2></section>
<section id="contact"><h2>Contact</h2></section>
<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>
</html>
```

### Embedding video via the HTML `<body>` tag

If you want to embed a video on your website, the `<body>` section is the correct (and only) place to do so. Below is an example of how to embed a video:

```html

<html>
<head>
<title>Website with a video</title>
</head>
<body>
<video width="320" height="240" controls>
<source src="example-film.mp4" type="video/mp4">
</video>
<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>
</html>
```

### Changing the design of content via HTML `<body>` tag

With the help of [CSS](https://www.ionos.com/digitalguide/websites/web-design/css-coding-made-easy/), you can also use the `<body>` area to customize the design of your web content. You can see how this works in the following example:

```html

<html>
<head>
<title>HTML body with visual adjustments</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #BFEFFF;
}
h1 {
color: black;
}
</style>
</head>
<body>
<h1>Here’s your heading</h1>
<p>Here’s your website content.</p>
<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>
</html>
```

### Customizing backgrounds in HTML `<body>`

If you want to change your [HTML background](https://www.ionos.com/digitalguide/websites/web-development/html-backgrounds/) with CSS, you can also do so in the HTML `<body>`. Here’s how to set the background color:

```html

<html>
<head>
<title>HTML body with new background color</title>
<style>
body {
background-color: #BFEFFF;
}
</style>
</head>
<body>
<h1>Here’s your heading</h1>
<p><a href="https://www.example-website.com">Visit example-website.com!</a></p>
<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>
</html>
```

To insert an image, use the code below:

```html

<html>
<head>
<title>HTML body with new background image</title>
<style>
body {
background-image: url(example.png);
}
</style>
</head>
<body>
<h1>Here’s your heading</h1>
<p><a href="https://www.example-website.com">Visit example-website.com!</a></p>
<div class="hash d-none" hidden>hash_9e94a5947fa4b5fb94ae96a4a95f6a5bd557de9e</div><script data-shy-copy-guard>(function(){var C=[0x00AD,0x200B,0x200C,0x200D,0x2060,0xFEFF];var s=function(t){for(var i=0;i<C.length;i++){t=t.split(String.fromCharCode(C[i])).join("");}return t;};document.addEventListener("copy",function(e){var sel=document.getSelection();if(!sel||sel.isCollapsed||!e.clipboardData){return;}e.clipboardData.setData("text/plain",s(sel.toString()));try{var d=document.createElement("div");d.appendChild(sel.getRangeAt(0).cloneContents());e.clipboardData.setData("text/html",s(d.innerHTML));}catch(x){}e.preventDefault();});})();</script></body>
</html>
```


This is a markdown version of: [https://www.ionos.com/digitalguide/websites/web-development/html-body/](https://www.ionos.com/digitalguide/websites/web-development/html-body/) for AI/LLM consumption.