HTML <form> name attribute

Definition and Usage

name This attribute specifies the name of the form.

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

Example

HTML Form with Name Attribute:

<form action="/action_page.php" method="get" name="myForm">
  <label for="fname">First 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="button" onclick="formSubmit()" value="Send form data!">
</form>

Try It Yourself

Syntax

<form name="text">

Attribute Value

Value Description
text Specifies the name of the form.

Browser Support

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