Skip to: content, navigation

by Ian Lloyd

name (HTML attribute)

Spec
Depr. Version
Yes HTML 3.2
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
name="string"

Example

The following example shows a link with the name attribute of "mmm-cake":

<a href="cakes-ja.html" name="mmm-cake">lovely range
    of Japanese cakes (note: this link will take you to
    a page in Japanese language)</a>

Description

The name attribute is used to identify a link destination, or anchor, on a page. It has been superseded by the id attribute, but it’s still used for the purposes of backwards compatibility (see the section on the href attribute for more).

Value

This attribute takes a—preferably short—name of the author’s choosing. As this attribute will often be paired with a matching id attribute, you should observe the following rules regarding ids.

The id attribute value must begin with a letter in the roman alphabet (a–z or A–Z); this can be followed by any combination of letters (a–z or A–Z), digits (0–9), hyphens (-), underscores (_), colons (:), and periods (.). The id value is case sensitive, thus <span id="me">This is me</span> and <span id="ME">This is me</a> would be considered to be separate and uniquely identifiable elements on the same web page.

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

The use of the name attribute for the purposes of linking from one part of a page to another is well supported, but if your page is written in XHTML, this attribute’s inclusion will cause your page to be invalid.

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters