The `<div>` tag in HTML is a container that is used to group other HTML elements together. It's often used to structure and style content on a webpage. For example:
Example 1:
<div>
<h1>Hello, World!</h1>
<p>This is a paragraph inside a div.</p>
</div>
Here's a simple example using the `<div>` tag to group content:
Example 2:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Simple Example</title>
<style>
.box {
border: 1px solid black;
padding: 10px;
margin: 10px;
}
</style>
</head>
<body>
<div class="box">
<h2>Title</h2>
<p>This is some content inside a div.</p>
</div>
<div class="box">
<h2>Another Title</h2>
<p>More content in another div.</p>
</div>
</body>
</html>
In this example, each `<div>` with the class "box" acts as a container for a title and some content. The styling is applied with a simple CSS style to add borders, padding, and margins for a clearer visual separation.
You can apply styles or use it as a hook for JavaScript functions to manipulate its content.