HTML <main>元素呈现了文档<body>或应用的主体部分。主体部分由与文档直接相关,或者扩展于文档的中心主题、应用的主要功能部分的内容组成。这部分内容在文档中应当是独一无二的,不包含任何在一系列文档中重复的内容,比如侧边栏,导航栏链接,版权信息,网站logo,搜索框(除非搜索框作为文档的主要功能)。

属性

这个元素仅包含在全局属性中。

示例

<!-- other content -->

<main>
  <h1>Apples</h1>
  <p>The apple is the pomaceous fruit of the apple tree.</p>
  
  <article>
    <h2>Red Delicious</h2>
    <p>These bright red apples are the most common found in many
    supermarkets.</p>
    <p>... </p>
    <p>... </p>
  </article>

  <article>
    <h2>Granny Smith</h2>
    <p>These juicy, green apples make a great filling for
    apple pies.</p>
    <p>... </p>
    <p>... </p>
  </article>

</main>

<!-- other content -->

规范

Specification Status Comment
HTML Living Standard
<main>
Living Standard  
HTML 5.1
<main>
Recommendation No change from HTML5.
HTML5
<main>
Recommendation Initial definition.

浏览器支持

<main>标签被广泛支持(除了IE. 建议直到<main>元素被IE 浏览器所支持,  "main" ARIA 语义 才会加入 <main> 元素:

<main role="main">
  ...
</main>

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 26Edge Full support 12Firefox Full support 21IE No support NoOpera Full support 16Safari Full support 7WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support 12Firefox Android Full support 21Opera Android Full support YesSafari iOS Full support 7.1Samsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support

参见

文档标签和贡献者

此页面的贡献者: zhangchen, yuyang, beiweiqiang, pantao, holynewbie, TANRUI, oxygen16
最后编辑者: zhangchen,