Export to GitHub

doctype-mirror - ANameAttribute.wiki


You are here: Home > HTML Reference > Elements > <a> element > name attribute

Usage

In the <a> element, the name attribute defines a placeholder that can be used for bookmarking a section of a document.

HTML 4 states that the name attribute "shares the same namespace as the id attribute." This means that you can't have an element <a name="foo"> and have a separate element <a id="foo"> in the same document. It's OK for a single element to have both attributes, as long as they have the same value: <a name="foo" id="foo">.

XHTML 1.0 deprecates the name attribute in favor of the id attribute.

HTML 5 and XHTML 1.1 do not include the name attribute at all.

Other elements have a name attribute, but it means something else.

Browser compatibility

Compatibility table legend

| Test | IE8 | IE7 | IE6 | FF3 | FF2 | Saf3 | Op9 | Chrome | |:---------|:--------|:--------|:--------|:--------|:--------|:---------|:--------|:-----------| | a.name reflects <a name="foo"> | Y | Y | Y | Y | Y | Y | Y | Y |

Further reading