HTML5 主要元素与 ARIA 地标角色 ="main"

标签 html accessibility wai-aria

我有兴趣了解更多关于 HTML5 <main> 之间的关系和可能的区别。元素和 ARIA 地标角色属性 role="main" .

我的印象是 <main> 的目的元素是映射 ARIA 滚动属性 role="main"到特定的 HTML 元素上。但这就是总结吗?

使用 <main> 有什么好处吗?比方说,<div role="main"> ?或者,在现在和可预见的 future ,这些会产生相同的结果吗?

如果能对以下示例进行比较,我们将不胜感激:

<body>
  <main>
    <p>Paragraph</p>
  <main>
</body>

<body>
  <main role="main">
    <p>Paragraph</p>
  <main>
</body>

<body>
  <div role="main">
    <p>Paragraph</p>
  <div>
</body>

最佳答案

根据 HTML5 Doctor,它们是等价的。 <main>只是让实现变得更容易和更整洁 role="main" .

The primary purpose of is to map ARIA’s landmark role main to an element in HTML.

这里是对 <main> 的一般描述元素。

The main element represents the main content of the body of a document or application. The main content area consists of content that is directly related to or expands upon the central topic of a document or central functionality of an application.

推荐

建议同时使用 <main>role="main"在同一元素中,直到浏览器实现 <main>

<!-- Recommended -->
<main role="main">
    ...
</main>

请务必阅读 <main> spec如果你有兴趣。

切片注意事项

正如 Szabolcs 在评论中指出的那样,<main>不是分段元素,因此应与 <section> 结合使用元素。

引用资料

关于HTML5 主要元素与 ARIA 地标角色 ="main",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19595719/

相关文章:

html - 居中显示 : table-cell used to bottom align 的 div 内容

javascript - 更改png图像背景颜色

html - 语义 'correct' 使用 CSS 设计标签样式的方法 :checked property

accessibility - 元素可访问性显示为 "Ensure markup documents contain well-formed elements"

html - 如何为某些 HTML 页面部分的屏幕阅读器设置优先级?

javascript - 为什么javascript找不到元素?

javascript - 如何删除背景图像溢出?

angular - 辅助功能-Angular 中的路线更改时焦点丢失

javascript - 将 aria 用于可扩展元素

javascript - 有没有办法阻止 HTML accesskey =""被激活?