English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <form> name attribute

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

 HTML <form> tag

Online Example

HTML form with name attribute:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML <form> name Attribute Usage-Basic Tutorial(oldtoolbag.com)</title>
<script>
function formSubmit() {
    document.forms["myForm"].submit();
}
</script>
</head>
<body>
<form name="myForm" action="action_page.php" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br><br>
<input type="button" onclick="formSubmit()" value="Send form data!">
</form>
<p>Note that the JavaScript in the header uses the form's name to specify the form to be submitted.</p>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the name attribute.

Definition and Usage

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

HTML 4.01 With HTML5Differences

None.

Differences between HTML and XHTML

In XHTML, the name attribute is deprecated. Please use the id attribute instead.

Syntax

<form name="text">

Attribute value

ValueDescription
textSpecifies the name of the form.
 HTML <form> tag