Horje

How to add HTML <form> name Attribute

An HTML form with a name attribute.

Definition and Usage

The name attribute specifies the name of a form.

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


Browser Support

Syntax

<form name="text">

Attribute Values

Value Description
text Specifies the name of the form
index.html
Example: HTML
<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">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <input type="button" onclick="formSubmit()" value="Send form data!">
</form> 

Output should be:

How to add HTML <form> name Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin