Search
Close this search box.

Named anchors in HTML5

The traditional way to create named anchors (bookmarks) on a page was to use

<a name="top">Top of page</a>

If you are working in HTML5 you’ll find that your web editors intellisense (if you have a decent one) highlights this as an error, although it will still work in current browsers.

If this really is a syntax error, what’s the valid HTML5 way of doing this?

Well, it’s very simple and has been supported by most browsers for several versions, you give the anchor/bookmark an ID and target that in your link.

<h1 id="top">My web page</h1>

with the ‘top of page’ link being

<a href="#top">Top of page</a>

Posted on Friday, July 12, 2013 2:04 AM HTML5 , Anchor | Back to top

This article is part of the GWB Archives. Original Author: IHAYNES

Related Posts