HTML <input> name Attribute

The name attribute on an <input> tag assigns a name to that input element. This name is used during form submission and as a reference for other purposes.

Example

#

A name attribute on two <input> elements.
Two textbox values are sent during form submission.





<form action="/tutorial/action.html">
  <label for="firstname">Firstname:</label><br />
  <input type="text" id="firstname" name="firstname"><br />
  <label for="lastname">Lastname:</label><br />
  <input type="text" id="lastname" name="lastname"><br />

  <input type="submit" value="Submit">
</form>

Using name

The name attribute assigns a name to the input element.

Unlike id, the name does not have to be unique across the page.

This attribute is used as reference for JavaScript and for form data submission.

Note: Input elements must have a name to participate in form submission.


Syntax

<input name="name">

Values

#

name Description
name String value. Name of the input element. Required for form submission.

Browser support

Here is when name support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <input>
Guides