
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML
The form attribute of the <button> element is used to specify the forms wherein the button belongs to.
Following is the syntax −
<button form="id">
The id above is the if of the form wherein the button belongs to.
Let us now see an example to implement the form attribute of the <button> element−
Example
<!DOCTYPE html> <html> <body> <h2>Points</h2> <form action="" method="get" id="form1"> Player: <input type="text"><br> Rank: <input type="number"><br> Points: <input type="number"><br> </form> <button type="submit" form="form1" value="Submit">Click to Submit</button> </body> </html>
This will produce the following output. The button is part of the form−
In the above example, we have set a form and added form elements−
<form action="" method="get" id="form1"> Player: <input type="text"><br> Rank: <input type="number"><br> Points: <input type="number"><br> </form>
With that, we have set a button outside the form−
<button type="submit" form="form1" value="Submit">Click to Submit</button>
Since we have set the form id in the button, therefore it would still belong to the same form. This is possible using the <button> form attribute.
- Related Articles
- HTML Form action Attribute
- HTML Form method Attribute
- HTML maxlength Attribute
- HTML wrap Attribute
- HTML checked Attribute
- HTML datetime Attribute
- HTML value Attribute
- HTML coords Attribute
- HTML hreflang Attribute
- HTML cite Attribute
- HTML cite Attribute
- HTML autocomplete Attribute
- HTML max Attribute
- HTML placeholder Attribute
- HTML required Attribute

Advertisements