Definition
The <body>
HTML element represents the main content area of an HTML document. It encapsulates all the visible content that users see when they visit a webpage. The <body>
element should be placed directly inside the <html>
element.
Here’s an example of the basic structure of an HTML document with the <body>
element:
<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<h1>Welcome to My Webpage</h1>
<p>This is the main content of the webpage.</p>
</body>
</html>
In this example, the <body>
element contains a heading (<h1>
) and a paragraph (<p>
), representing the main content of the webpage.
The <body>
element can contain various types of content, such as text, headings, paragraphs, images, links, lists, forms, and more. It serves as a container for all the visible elements and provides the structure for the webpage’s content.
You can apply CSS styles and JavaScript functionality to the <body>
element to control the appearance and behavior of the content within it.
It’s important to note that there should be only one <body>
element per HTML document, and it should contain all the visible content of the webpage.