HTML <button> formAttribute

HTML button 标签参考手册HTML <button> Tag

Example

A submit button located outside the form (but still part of the form):

<form action="demo-form.php" method="get" id="nameform">
First name: <input type="text" name="fname" /><br>
Last name: <input type="text" name="lname" /><br>
</form>

<p>The button below is outside the form element, but is still part of the form.</p>

<button type="submit" form="nameform" value="Submit">Submit</button>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Except for Internet Explorer, all other major browsers support the form attribute.


Definition and Usage

The form attribute specifies that a button belongs to one or more forms.


Differences between HTML 4.01 and HTML5

The form attribute is a new attribute in HTML5.


Syntax

<button form="form_id">

Attribute Values

Value Description
form_id The id of the form the button belongs to. To reference more than one form, use a space-separated list.


HTML button 标签参考手册HTML <button> Tag Other Extensions