HTML <input> name attribute

Definition and Usage

name The attribute specifies the name of the <input> element.

name The attribute is used to reference elements in JavaScript or to reference form data after submitting a form.

Note:Only the name The form element with the attribute can pass their values when submitting the form.

Example

An HTML form that contains three input fields: two text fields and one submit button:

<form action="/action_page.php">
  <label for="fname">Name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Surname:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="submit" value="Submit">
</form>

Try It Yourself

Syntax

<input name="text">

Attribute Value

Value Description
text Specify the name of the <input> element.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support