aria 里程碑式的角色,仅适用于容器?
我正在现有的 html 布局上实现 ARIA 里程碑角色。我需要更改的代码越少越好。我发现的所有示例都使用整个容器的地标。 例如。
<div id="content" role="main">
<p>....</p>
<ul>...</ul>
</div>
在我的模板中,并不总是有一个容器包围我不想标记为 ARIA 地标的内容。有时,对于实现来说,不标记整个容器,而只在相关内容的开头设置标记会更容易。
所以它看起来像这样:
<div role="main"></div>
<p>....<p>
<ul>...</ul>
从语义的角度来看,屏幕阅读器或其他软件并不确切知道内容何时结束,或者可能认为内容是空的。这会是一个问题吗?
我用 JAWS 屏幕阅读器测试了它,它的行为似乎是一样的。 JAWAS 只寻找里程碑的开始。 这是一条不归路吗?或者我可以这样使用它吗?
I'm implementing ARIA landmark roles on a existing html layout. The less code I need to change the better. All examples I found use the landmark for the whole container.
for example.
<div id="content" role="main">
<p>....</p>
<ul>...</ul>
</div>
In my templates there isn't always a container surrounding the content I wan't to mark as ARIA landmark. Sometimes it would be easier, for the implementation, not to mark the whole container, but only to set a mark to the beginning of the relevant content.
So it would look like this:
<div role="main"></div>
<p>....<p>
<ul>...</ul>
From the semantic point of view the screenreader or other software doesn't know exactly when the content ends or perhaps thinks the content is empty. Could this be a problem?
I tested it with the JAWS screenreader, it seems to behave the same. JAWAS only looks for the beginning of a landmark.
Is this a no-go? Or could I use it this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
嗯,这里发生了一些事情。
首先,虽然屏幕阅读器最好都表现自己并以相同的方式行事,但我的经验是,这更像是浏览器战争,因此 role="main" 的使用对于不同的读者来说会产生不同的效果,不一定对你有帮助。
顺便说一句,你是对的 - 任何角色属性都无法识别内容何时结束,到目前为止我所见过的支持 ARIA 的每个人都是这种情况(而且只有少数)。
最后,我的建议是——我认为你应该使用不同的角色。区域角色更加通用,但仍然可以帮助用户指定重要内容的位置。另一方面,如果您想让它真正通用并且跨屏幕阅读器可用,请完全放弃角色概念并添加一个隐藏的 h2 标头标签,其中包含您想要称呼它的任何内容。虽然它并不花哨,但它保证可以工作,并且 a11y 社区中没有人会对此抱怨。
就这样,使用像区域这样的通用角色来标记它,或者更好的是,完全放弃角色想法并返回到样板 h2 标签以获得统一兼容性。
Well, there is a couple things going on here.
First, while it would be nice for the screen readers to all behave themselves and act the same way, my experience is that it's more like browser wars, so the use of role="main" is going to turn out different for different readers and not necessarily all that helpful to you.
You are right, by the way - there is no recognition on the part of any role attribute in terms of when the content ends, and that is the case everyone that I've seen supporting ARIA thus far (and there's only a few).
So finally, my advice - I think you should use a different role. The region role is a lot more generic but will still help the user designate where important content is. On the other hand, if you want to keep it really generic and cross-screen reader usable, drop the role concept altogether and slap in a hidden h2 header tag that says whatever you are looking to call it. While it isn't fancy, it's guaranteed to work and nobody in the a11y community is going to squawk about it at all.
So there it is, use a generic role like region to mark it up, or better yet, scrap the role idea altogether and head back to the boilerplate h2 tag for uniform compatibility.
同意,这只是内容的开始。既然如此,为什么不直接将 role="main" 放在您考虑启动主要内容的第一个元素上,而不是创建一个空 div 呢?在上面的示例中,这将是
标记。
role="main" 的另一种使用方式是为“跳到主要内容”链接提供锚点。这也支持将角色放置在
标记上的方法。
简而言之,如果他们使用辅助技术中的跳过链接或捷径,您希望他们跳转到哪里?我只看到增强导航方面的收益,它被认为是一个“里程碑”角色......这对我来说,提供了一个里程碑。
Agreed, it just marks the beginning of the content. That being the case, instead of creating an empty div why not just put the role="main" on the first element you would consider to start the main content? In your example above this would be the
<p>
tag.The other way role="main" can be used is to provide an anchor for a 'skip to main content' link. This also supports the approach of placing the role on the
<p>
tag.In short, where do you want them to jump to if they use the skip link or use a short cut in the assistive technology? I only see gains in enhanced navigation, it is considered a 'landmark' role... and this to me, provides a landmark.
我绝不是 WAI-ARIA 方面的专家(尽管最近了解了更多),但我的理解是,读者实际上了解角色标记区域中包含的内容,而不仅仅是了解标记区域开始的位置。
此外,引用此处:
为此,您可能需要比您希望的更多地修改模板。
I am in no way an expert on WAI-ARIA (learning more lately though), but my understanding is that readers do in fact understand about content being contained within a role-marked region, not only about the location where the marked region starts.
Furthermore, to quote from here:
To do that, you may need to modify your templates more than you were hoping.