Short Note About HTML Anchor Bookmarks

This is totally rediculous, but it’s a fact. Some version of Microsoft Internet Explorer do not handle empty anchors at all! Unlike Firefox, Safari and the rest, IE simply doesn’t see them, so anchors lead to nowhere (top of the page). This is just a note for you (and me) to keep your anchors filled with something, at least a whitespace character ;)

<a name="bookmark"></a>Bookmark Text <!-- Bad! -->
<a name="bookmark">Bookmark Text</a> <!-- Good! -->

Keep that in mind ;) Cheers!

About the author

Konstantin Kovshenin

WordPress Core Contributor, ex-Automattician, public speaker and consultant, enjoying life in Moscow. I blog about tech, WordPress and DevOps.

7 comments

    • You sometimes have to link to "nowhere", and as Moja mentioned below the crucial problem is with styling, so an empty anchor is the short-cut, for Firefox and the others.

      Anyways, there are so many tags out there that are allowed (or sometimes even restricted, img br hr) to be empty, why can't an anchor be? It's not fair ;)

      ~ K.

    • The notion that content could exist _within_ a line break or horizontal rule is absurd! (I can imagine rare instances where being allowed to include text between the opening and closing tags of an img element could be useful – a photograph of a street sign, perhaps – but we already have the alt attribute for fallback content.)

      An anchor, on the other hand, generally (always?) requires content in order to be useful. To interact with a link, one needs something on which to click (or an indication of when the link gains focus during keyboard navigation). Ideally, one should also have a good idea of what to expect from the link, based on its descriptive label. Empty anchors fail in both of these respects.

      Can you describe an instance in which empty anchors are useful?

  • From my experience I think it is; e.g. in some shopping cart system the same empty a name="bookmark" _ /a is used to point the cart area into visible window when a customer adds a product. IE sucks here a big time again. Nor we can style it as is by CSS, for this reason I actually had to place it withing one extra div element (spending 2 hours) to avoid breaking that area in IE. All other browsers don't make this error which I encountered, only IE so the browser bugs in this instance again.