html - 角色="banner"的上下文是什么

标签 html accessibility w3c wai-aria

在 W3C ARIA 示例页面中 Banner Landmark HTML Techniques 选项卡中有这样的文本:(强调我的)

  • The HTML5 header element defines a banner landmark when its context is the body element.
  • The HTML5 header element is not considered a banner landmark when it is descendant of any of following elements:
    • article
    • aside
    • main
    • nav
    • section

据我了解,此代码中的 header 不会自动设置横幅角色:

<body>
  <main>
    <article>
      <header><!-- ... --></header>
    </article>
  </main>
</body>

但是,如果 header 不嵌套在上述任何元素中,同时body 元素的直接后代,那又怎么样呢?
这段代码中的header是否自动设置了banner角色?

<body>
  <div>
    <header><!-- ... --></header>
    <main></main>
  </div>
</body>

元素/header 元素的上下文是什么?
它只是元素的直接父元素吗?
或者它是设置上下文的最接近的祖先元素?

我在 Roles documentation 中找不到任何提示在 w3.org 上,该页面上多次提到了“上下文”一词,但与示例页面上提到的上下文不同(双关语)。

最佳答案

official <header> element spec提供了更多的说明,尽管您可能需要阅读几次才能理解。

When a <header> element’s nearest ancestor sectioning root element is the <body> element, and it is not a descendant of the <main> element or a sectioning content element, then that <header> is scoped to the <body> element and represents mostly site-oriented content, or introductory content for the page as a whole.

接着说:

Assistive Technology may convey to users the semantics of the header element when it applies to the whole page. This information can provide a hint as to the type of content. For example, the role of the element, which in this case is "banner", can be announced by screen reader software when a user navigates to a header element that is scoped to the body element.

所以如果你的<header>不属于 <body> 的范围,屏幕阅读器很可能不会将标题宣布为横幅地标,但这取决于屏幕阅读软件来决定。

关于html - 角色="banner"的上下文是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56983798/

相关文章:

android - TextInputLayout,setError增加高度

ios - 画外音读取 tableview 中的所有单元格

xhtml - <td align ="left"valign ="top"> 为什么这不会在 W3C 验证器中产生错误?

Powershell IIS 日志耗时大于

html - 防止在 div 上滚动

javascript - 通过单击弹出窗口外部来关闭弹出窗口

ios - 使用旧金山字体将 HTML 解析为 NSAttributedString? (iOS 9)

html - 如何在最小化的同时保持视频的完整尺寸?

javascript - 如何在开发html/js/css时进行MVC?

html - 如何在悬停父元素时向子元素添加 CSS3 过渡