HTML教程-HTML<main>标签

HTML <main>
标签 用于表示 <body>
标签的主要内容。
<main>
标签位于 <body>
标签内部。它用于准确描述页面的主要内容。
<main>
标签的内容直接与文档的中心主题相关。
HTML <main>
是一个新的标签,引入自 HTML5。
需记住的要点:
作者不应在一个文档中包含多个 <main>
标签。
<main>
元素不应作为 <article>
、<aside>
、<header>
、<footer>
或 <nav>
元素的子元素。
HTML <main>
标签及其子元素可以轻松地通过 CSS 进行样式设置。
HTML <main>
标签示例
<main>
<h2>Apples</h2>
<p>The apple is a red color pomaceous fruit of the apple tree. It is a very famous saying about apple.</p>
<br> "An apple in a day, keeps the Doctor away".
<article>
<h3>Red Delicious</h3>
<p>These bright red apples are the most common found in many supermarkets.</p>
</article>
<article>
<h3>Granny Smith</h3>
<p>These juicy, green apples make a great filling for apple pies.</p>
</article>
</main>
输出:
Apples
The apple is a red color pomaceous fruit of the apple tree. It is a very famous saying about apple. "An apple in a day, keeps the Doctor away".
Red Delicious
These bright red apples are the most common found in many supermarkets.
Granny Smith
These juicy, green apples make a great filling for apple pies.
<main>
标签还支持 HTML5 中的全局属性和事件属性。
支持的浏览器
元素 | ![]() | ![]() | ![]() | ![]() | ![]() |
---|---|---|---|---|---|
<main> | 是 | 否 | 是 | 是 | 是 |