WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: bookmark hyperlinks and accessibility

for

From: jukka.korpela
Date: Feb 19, 2002 12:52AM



Tarek Alaaeddin wrote:

> I am having trouble with
> <a Name="content"></a> with hyperlink bookmark tag.

The first thing to note is that although an <a> element with empty content
as above (that is, with nothing between the <a ...> and </a> tags) is
formally allowed by HTML syntax, it is advisable to put some content there.
Typically, you would put a few words there. By the syntax, the content is
limited to text and text-level markup, so you cannot put e.g. an <h1>
heading element there. But you can nest them the other way around, and
that's what I normally recommend:
<h1><a name="content">Getting Started with Life</a></h1>
Usually when you wish to put an anchor ("bookmark") element into a page,
it's a location where some heading is adequate.

This is indirectly an accessibility issue in the sense that although there
are just a few and probably rarely used browsers that cannot handle <a>
elements with empty content, people will special needs use "different",
rare browsers more often. Besides, the problem can easily be avoided, and
it usually makes the markup a bit more logical.

> I have two in one page, and for some reason, it keep going to the second
one
> not the first one, when user clicks on that link for instance
> <a href="#content">Skip to main content</a>

Then you have an error on the page. The anchors used in <a name="...">
_must_ be unique within a document, by HTML rules. What could be the reason
for having two identical anchors? If you assume that a browser should go to
the first when the link above is followed, then you would need to assume
that the second one cannot be used at all, for any purpose of linking.
Besides, the assumption is wrong. There is no specification of what should
happen when you violate HTML rules by having two anchors with the same
name. Anything may happen. (A browser could jump to either anchor, or
neither, or start playing a violin, perhaps depending on the phase of the
moon. Sorry, we old programmers use weird language when trying to make it
clear that "undefined" can mean just anything.)

Is there some reason why the problem cannot be solved by changing the name
of the second anchor?

--
Jukka K. Korpela, erityisasiantuntija / senior adviser
TIEKE Tietoyhteiskunnan kehitt