Same page references, or named anchors

Named anchors have been around since HTML was created and allowed you to link to a different part of a page. They can be referenced by external page by using a hash then the identifier after the URL:

<a href="http://site.com/#section1">Go to first section</a>

If present, the attribute NAME allows the anchor to be the destination of a link. The value of the attribute is an identifier for the anchor. Identifiers are arbitrary strings but must be unique within the HTML document. Another document can then make a reference explicitly to this anchor by putting the identifier after the address, separated by a hash sign.

Hypertext Markup Language (HTML) Internet Draft

Named anchor (deprecated/obsolete)

Named anchors were most commonly empty anchor tags, inserted just above the area of the page you wanted to link to.

<a name="section1"></a>

The use of the name attribute was deprecated in HTML5 and XHTML1.0 and removed completely in XHTML1.1.

Same page reference (current/new)

Instead of using an anchor with a name attribute, use an id on any existing element where you want to link to.

<h2 id="section1">Section One</h2>

One comment

Add your comment

Your email address will not be published. Required fields are marked *