HTML5主要元素与ARIA地标角色=“main" [英] HTML5 main element versus ARIA landmark role="main"
问题描述
我有兴趣了解更多关于 HTML5 <main>
元素和 ARIA 地标角色属性 role="main"
之间的关系和可能的区别代码>.
我的印象是 元素的目的是将 ARIA roll 属性
role="main"
映射到特定的 HTML 元素.但这能概括吗?
使用 比使用
对比较以下示例的任何见解将不胜感激:
<主要><p>段落</p><主要>
<主要角色=主要"><p>段落</p><主要>
<div role="main"><p>段落</p><div>
根据 HTML5 Doctor,它们是等效的. 只是让
role="main"
的实现更简单、更整洁.
主要目的是将 ARIA 的地标角色 main 映射到 HTML 中的元素.
这里是 元素的一般描述.
main
元素表示文档或应用程序的 body
的主要内容.主要内容区域由与文档的中心主题或应用程序的中心功能直接相关或扩展的内容组成.
推荐
建议在同一个元素中同时使用 和
role="main"
直到浏览器实现 代码>正确.
<主要角色=主要">...</main>
请务必阅读<main>
spec 如果您有兴趣.
切片注意事项
正如 Szabolcs 在评论中指出的那样, 不是分段元素,因此它应该与
元素结合使用.
参考资料
I'm interested to learn more about the relationship, and possible distinctions, between the HTML5 <main>
element, and the ARIA landmark role attribute role="main"
.
I'm under the impression that the purpose of the <main>
element is to map the ARIA roll attribute role="main"
onto a specific HTML element. But does that sum it up?
Are there benefits to using <main>
over, say, <div role="main">
? Or will these, for now and the foreseeable future, yield the same result?
Any insights in comparing the following examples would be greatly appreciated:
<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>
According to HTML5 Doctor they are equivalent. <main>
just makes it easier and neater to implement role="main"
.
The primary purpose of is to map ARIA’s landmark role main to an element in HTML.
Here is a general description of the <main>
element.
The
main
element represents the main content of thebody
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.
Recommendation
It is recommended to use use both <main>
and role="main"
in the same element until browsers implement <main>
properly.
<!-- Recommended -->
<main role="main">
...
</main>
Be sure to read the <main>
spec if you're interested.
Note on sectioning
As Szabolcs points out in the comments, <main>
is not a sectioning element so it should be used in conjunction with a <section>
element.
References
这篇关于HTML5主要元素与ARIA地标角色=“main"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!