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.
Option 1. Use the 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.
Option 2. Add a 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.
Blah H2 Content
`? After all, that ids on arbitrary elements can be used as anchor points was specified in HTML 4.01 already. And everything else, using additional `a` elements, Iād consider just unnecessary bloat-y, unless there was a very specific reason to use them. ā CBroe Apr 25 '14 at 17:12