这篇翻译不完整。请帮忙从英语翻译这篇文章

HTML <main> 元素呈现了文档的 <body> 或应用的主体部分。主体部分由与文档直接相关,或者扩展于文档的中心主题、应用的主要功能部分的内容组成。

属性

此元素仅包含全局属性

使用说明

在文档中,<main> 元素的内容应当是独一无二的。任何同时存在于任意一系列文档中的相同、重复内容,比如侧边栏、导航栏链接、版权信息、网站 Logo,搜索框(除非搜索框为文档的主要功能),都不应当被包含在其内。

<main> 对文档的大纲(outline)没有贡献;也就是说,它与诸如 <body> 之类的元素,诸如 <h2> 之类的标题等不同,<main> 不会影响 DOM 的页面结构概念。它仅有提供信息的作用。(原文:It's strictly informative.)

示例

<!-- 其他内容 -->

<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>

<!-- 其他内容 -->

可访问性相关

界标 Landmark

The <main> element behaves like a main landmark role. Landmarks can be used by assistive technology to quickly identify and navigate to large sections of the document. Prefer using the <main> element over declaring role="main", unless there are legacy browser support concerns.

直达内容 Skip navigation

Skip navigation, also known as "skipnav", is a technique that allows an assistive technology user to quickly bypass large sections of repeated content (main navigation, info banners, etc.). This allows the user to access the main content of the page faster.

Adding an id attribute to the <main> element allows it to be a target of a skip navigation link.

<body>
  <a href="#main-content">Skip to main content</a>

  <!-- navigation and header content -->

  <main id="main-content">
    <!-- main page content -->
  </main>
</body>

阅读器模式 Reader mode

Browser reader mode functionality will look for the presence of the main element, as well as heading and content sectioning elements when converting content into a specialized reader view.

规范

规范 状态 备注
HTML Living Standard
<main>
Living Standard
HTML 5.1
<main>
Recommendation No change from HTML5.
HTML5
<main>
Recommendation Initial definition.

浏览器兼容性

<main> 标签受广泛支持。For Internet Explorer 11 and lower, it's suggested that an ARIA role of "main" be added to the <main> element to ensure it is accessible (screen readers like JAWS, used in combination with older versions of Internet Explorer, understand the semantic meaning of the <main> element when this role attribute is included).

<main role="main">
  ...
</main>
Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
mainChrome 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 YesFirefox 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

参见

文档标签和贡献者

最后编辑者: RainSlide,