main标签和div标签怎么一起用
时间: 2023-08-20 09:04:02 浏览: 72
可以使用 `main` 标签和 `div` 标签结合起来使用,来组织网页内容和样式。例如,可以将一篇文章的主要内容放在 `main` 标签中,再用多个 `div` 标签来分组不同的部分,方便进行样式设置或 JavaScript 操作。
下面是一个例子:
```html
<!DOCTYPE html>
<html>
<head>
<title>My Article</title>
</head>
<body>
<header>
<h1>My Article</h1>
</header>
<main>
<div class="intro">
<h2>Introduction</h2>
<p>This is the introduction to my article.</p>
</div>
<div class="body">
<h2>Body</h2>
<p>This is the main content of my article.</p>
<!-- more content here -->
</div>
<div class="conclusion">
<h2>Conclusion</h2>
<p>This is the conclusion to my article.</p>
</div>
</main>
<footer>
<p>Copyright © 2021 My Website</p>
</footer>
</body>
</html>
```
在这个例子中,`main` 标签包含了三个 `div` 标签,分别用来表示文章的引言、正文和结论。每个 `div` 标签都有一个类名,用来方便进行样式设置或 JavaScript 操作。