aria landmark roles, only for containers?
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 emp开发者_开发问答ty. 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?
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.
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.
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:
Probably the most important rule for applying landmarks is to ensure all content resides in a landmark region to ensure no content is orphaned. This way a screen reader user can safely use landmark navigation without missing content.
To do that, you may need to modify your templates more than you were hoping.
精彩评论