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

HTML Reference Manual

HTML Tag Directory

HTML: <input> form attribute

The form attribute specifies the form to which the <input> element belongs. Specifies one or more forms to which the <input> element belongs

 HTML <input> tag

Online Example

An input field located outside the HTML form (but still part of the form):

<!DOCTYPE html>
<html>
<head>
<title>HTML:<input> form attribute - 基础教程网(oldtoolbag.com)</title>
<body>
<form action="action_page.php" id="form1">
First name: <input type="text" name="fname"><br>
<input type="submit" value="Submit">
</form>
<p>The "Last name" field in the above <p> is outside the form element, but it is still part of the form.</>
Last name: <input type="text" name="lname" form="form1">
</html>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Almost all mainstream browsers support the form attribute except for Internet Explorer.

Definition and Usage

The form attribute specifies one or more forms that the <input> element belongs to.

HTML 4.01 and HTML5difference between

The form attribute is an HTML5 new attribute added in.

Syntax

<input form="form_id">

Attribute value

ValueDescription
form_idSpecify a list of one or more forms that the <input> element belongs to, separated by spaces.
 HTML <input> tag