html - 页眉和页脚标签是否应该在主标签内

标签 html

<分区>

我正在使用 main 标签 - 我应该将页眉和页脚标签放在 main 标签内还是应该分开?

还有,main标签需要role="main"吗?

最佳答案

来自 HTML5doctor 文章 The main element @Gaby 又名 G. Petrioli

tl;dr

经验法则:

  • 只有一个<main>每页;
  • 顶级元素(大多数情况下);
  • 不要将您网站的页眉/菜单/页脚(重复内容)放在您的 <main> 中.
  • 可以保留文章页眉/页脚如果特定

目的

The primary purpose of <main> is to map ARIA’s landmark role main** to an element in HTML. This will help screen readers and other assistive technologies understand where the main content begins. The W3C spec describes as representing:

规范说明

这是the draft spec says :

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.

页眉/页脚

Exclude site's header/footer/menu :

excludes content that is repeated across a set of documents such as site navigation links, copyright information, site logos and banners and search forms (unless the document or applications main function is that of a search form).

继续使用role='main'

但作为本文的旁注,Steve Faulkner 写道:

You should still use the ARIA role until all browsers map the role to the <main> element.

关于html - 页眉和页脚标签是否应该在主标签内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20470345/

相关文章:

html - 在 CSS 的 ID 末尾使用奇数/偶数定位 div

javascript - Jquery 比较选中的数据/对象差异

html - 用户代理应该如何处理 tabindex 和 z-index 的非整数值?

javascript - 函数未在 google script HTML 服务中执行

html - 页脚菜单未在 Safari 中显示

html - 为什么将 float 与 % 一起使用时 div 会消失?

CSS 不兼容 : Nivo Slider Pushes Elements of Page Awry

javascript - 无法通过 jquery 附加 HTML 文件

jquery - 图像在着陆时淡出

javascript - 带有 forEach 函数的 querySelectorAll 不适用于旋转木马幻灯片上的切换按钮