Reputation: 151
I've been trying to find in the WCAG or WAI guidelines the appropriate way to create a link anchor.
I currently have a site that has anchors like these:
<h2><a name="blah" id="blah">Blah H2 Content</a></h2>
but since I don't want to add unnecessary CSS just to cancel any anchor (no, they're not all in titles), I was wondering if this is accessible or if it violates WCAG or WAI-ARIA guidelines:
<h2><a name="blah" id="blah"></a>Blah H2 Content</h2>
Upvotes: 3
Views: 2408
Reputation:
There are two possible options I'd suggest, but first what I wouldn't recommend is having the empty anchor tag - <a name="blah" id="blah"></a>
. With this the anchor points to nothing, so if a screen reader attempts to extract a range of a tgas to it can determine what is in the page, this will be meaningless.
id
against a heading.<h2 id="blah">Blah H2 Content</h2>
If you want to have an anchor point against a heading, point it to that heading. Whith this in effect, you can stil use example.html/mypage.html#blah
to land at the correct point.
href
so the anchor is useful.<h2><a name="blah" id="blah" href="#blah">Blah H2 Content</a></h2>
If the anchor is useful to have for users, make it so they can get to it easily. By adding the href
attribute, a user can right click and get a link to that point in the document, middle click to focus a new tab on the point and share a link to that specific part of the document with another person.
Upvotes: 4