role="banner" 的上下文是什么
What is the context of role="banner"
在 Banner Landmark 的 W3C ARIA 示例页面中,HTML 技术 选项卡中有这段文字:(强调我的)
- 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 嵌套在上述元素的 none 中,而 不是 是 body
的直接后代呢?元素?
这段代码中的header是否自动设置了banner角色?
<body>
<div>
<header><!-- ... --></header>
<main></main>
</div>
</body>
什么 是 element/the header
元素的上下文?
是不是只有元素的直接parent?
还是设置上下文的最接近的祖先元素?
我在 w3.org 的 Roles documentation 中找不到任何提示,该页面上多次提到 context 这个词,但没有在示例页面中提到的相同上下文中(双关语)。
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>
范围内,屏幕 reader 很可能不会将 header 宣布为横幅地标,但它有点由屏幕阅读软件决定。
在 Banner Landmark 的 W3C ARIA 示例页面中,HTML 技术 选项卡中有这段文字:(强调我的)
- The HTML5
header
element defines abanner
landmark when its context is thebody
element.- The HTML5
header
element is not considered abanner
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 嵌套在上述元素的 none 中,而 不是 是 body
的直接后代呢?元素?
这段代码中的header是否自动设置了banner角色?
<body>
<div>
<header><!-- ... --></header>
<main></main>
</div>
</body>
什么 是 element/the header
元素的上下文?
是不是只有元素的直接parent?
还是设置上下文的最接近的祖先元素?
我在 w3.org 的 Roles documentation 中找不到任何提示,该页面上多次提到 context 这个词,但没有在示例页面中提到的相同上下文中(双关语)。
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>
范围内,屏幕 reader 很可能不会将 header 宣布为横幅地标,但它有点由屏幕阅读软件决定。