In the past I've seen examples of anchors being specified using anchor elements, and id
or name
attributes (with id taking precedence).
However, is there any particular reason why I should use an anchor element over any other element, in terms of accessibility/cross-browser support?
For example I could a URL http://domain.com/page.htm#faq with the following markup:
<a id="faq"></a>
<h1>Frequently Asked Questions</h1>
Which could be simplified to:
<h1 id="faq">Frequently Asked Questions</h1>
Is there any harm in using this second markup? Is there a particular reason why developers would prefer empty anchors over attaching the id
to a more relevant element?