Skip to: content, navigation

by Ian Lloyd

name (HTML attribute)

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

Example

The name attribute provides a way of referencing the input data:
<form>
<label for="pin">Your 4-digit PIN:</label>
<input type="password" name="pin" id="pin" maxlength="4" size="6" />
…
</form>

Description

The name attribute is used for referencing form data after it is submitted (it can also be referenced by JavaScript client-side using this attribute). Unlike the id attribute - which must have a unique value when applied to each form control - the name attribute may be applied to numerous form controls with the same value (although in practice this only happens with radio input buttons). Note that only form elements that have a name attribute will have their values passed through to the page/script specified in the form’s action attribute.

Value

Any name that the developer chooses (not containing spaces or special characters).

Compatibility

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

Causes no compatibility issues. It has excellent support across all tested browsers.

User-contributed notes

ID:
#1
Date:
Fri, 28 Mar 2008 11:17:05 GMT
Contributed by:
AutisticCuckoo

It's not true that using the same name for multiple form controls only happens with radio buttons. It's quite a common approach when you have a large number of checkboxes, too, although not all server-side technologies support it. (Perhaps not all browsers, either, for that matter.)

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