In HTML, the <body>
element is a crucial part of the structure, representing the content of an HTML document. It contains all the visible content that users see on a web page, including text, images, links, forms, and more. Here are some examples of how to use the <body>
element in HTML:
html<!DOCTYPE html>
<html>
<head>
<title>Your Page Title</title>
</head>
<body>
<!-- Your content goes here -->
<h1>Hello, World!</h1>
<p>This is a basic HTML document.</p>
</body>
</html>
html<body>
<h1>Heading 1</h1>
<p>This is a paragraph of text.</p>
<p>Another paragraph with <strong>strong</strong> and <em>emphasized</em> text.</p>
</body>
html<body>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<ol>
<li>First</li>
<li>Second</li>
<li>Third</li>
</ol>
</body>
html<body>
<a href="https://www.example.com">Visit Example.com</a>
</body>
html<body>
<img src="image.jpg" alt="Description of the image">
</body>
html<body>
<form action="/submit" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Submit">
</form>
</body>
html<body>
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
</body>
html<body>
<div style="background-color: lightblue; padding: 10px;">
<h2>Styled Division</h2>
<p>This is a styled division with a light blue background.</p>
</div>
</body>
These examples showcase the versatility of the <body>
element in HTML, allowing you to structure and present content on your web pages. Remember that the <body>
element should contain all the visible content, while the <head>
section is used for meta-information, scripts, and links to external resources.