Description
The <form>
tag defines an HTML form that contains interactive controls which enable a user to submit information to a web server. An HTML form is used to capture user information such as username, password, address details, credit card information, and so on.
Information can be captured in the form using many different form controls, such as <input>
, <textarea>
, <select>
, <option>
, <button>
. There are also labeling and grouping controls, which include the <optgroup>
, <fieldset>
, <legend>
, and <label>
elements.
The following table summarizes the usages context and the version history of this tag.
Placement: | Inline |
---|---|
Content: | Block, inline, and text, but not containing <form> elements |
Start/ End Tag: | Start tag: required, End tag: forbidden |
Version: | HTML 2, 3.2, 4, 4.01, 5 |
Syntax
The basic syntax of the <form>
tag is given with:
HTML/XHTML: <form action="URL" method="get|post"> ... </form>
The example below shows the <form>
tag in action.
<form action="action.php" method="post">
<p>
First name: <input type="text" name="first-name">
<button type="submit" value="Submit">Submit</button>
<button type="reset" value="Reset">Reset</button>
</p>
</form>
Tag-Specific Attributes
The following table shows the attributes that are specific to the <form>
tag.
Note: The default value for the enctype attribute is application/x-www-form-urlencoded. The value multipart/form-data should be used in combination with the INPUT element (when type="file").
Global Attributes
Like all other HTML tags, the <form>
tag supports the global attributes in HTML5.
Event Attributes
The <form>
tag also supports the event attributes in HTML5.
Browser Compatibility
Element | |||||
---|---|---|---|---|---|
<form> | Yes | Yes | Yes | Yes | Yes |
- Installation
- HTML <a> Tag
- HTML <abbr> Tag
- HTML <acronym> Tag
- HTML <address> Tag
- HTML <applet> Tag
- HTML <area> Tag
- HTML <article> Tag
- HTML <aside> Tag
- HTML <audio> Tag
- HTML <base> Tag
- HTML <b> Tag
- HTML <basefont> Tag
- HTML <bdi> Tag
- HTML <bdo> Tag
- HTML <big> Tag
- HTML <blockquote> Tag
- HTML <br> Tag
- HTML <body> Tag
- HTML <center> Tag
- HTML <button> Tag
- HTML <cite> Tag
- HTML <canvas> Tag
- HTML <caption> Tag
- HTML <code> Tag
- HTML <col> Tag
- HTML <dd> Tag
- HTML <colgroup> Tag
- HTML <dfn> Tag
- HTML <del> Tag
- HTML <div> Tag
- HTML <dl> Tag
- HTML <details> Tag
- HTML <dt> Tag
- HTML <em> Tag
- HTML <embed> Tag
- HTML <fieldset> Tag
- HTML <figure> Tag
- HTML <figcaption> Tag
- HTML <font> Tag
- HTML <footer> Tag
- HTML <datalist> Tag
- HTML <frameset> Tag
- HTML <frame> Tag
- HTML5 Global Attributes
- HTML <head> Tag
- HTML <header> Tag
- HTML <hgroup> Tag
- HTML <hr> Tag
- HTML <html> Tag
- HTML <iframe> Tag
- HTML <i> Tag
- HTML <form> Tag
- HTML <input> Tag
- HTML <keygen> Tag
- HTML <legend> Tag
- HTML <ins> Tag
- HTML <kbd> Tag
- HTML <li> Tag
- HTML <link> Tag
- HTML <map> Tag
- HTML <img> Tag
- HTML <mark> Tag
- HTML <menu> Tag
- HTML <meta> Tag
- HTML <meter> Tag
- HTML <nav> Tag
- HTML <noframes> Tag
- HTML <noscript> Tag
- HTML <object> Tag
- HTML <ol> Tag
- HTML <optgroup> Tag
- HTML <option> Tag
- HTML <output> Tag
- HTML <p> Tag
- HTML <param> Tag
- HTML <pre> Tag
- HTML <progress> Tag
- HTML <q> Tag
- HTML <rp> Tag
- HTML <rt> Tag
- HTML <ruby> Tag
- HTML <s> Tag
- HTML <samp> Tag
- HTML <script> Tag
- HTML <section> Tag
- HTML <select> Tag
- HTML <small> Tag
- HTML <source> Tag
- HTML <strike> Tag
- HTML <span> Tag
- HTML <style> Tag
- HTML <strong> Tag
- HTML <sub> Tag
- HTML <summary> Tag
- HTML <sup> Tag
- HTML <table> Tag
- HTML <tbody> Tag
- HTML <td> Tag
- HTML <textarea> Tag
- HTML <th> Tag
- HTML <tfoot> Tag
- HTML <thead> Tag
- HTML <source> Tag
- HTML <tr> Tag
- HTML <tt> Tag
- HTML <title> Tag
- HTML <u> Tag
- HTML <ul> Tag
- HTML <var> Tag
- HTML <video> Tag
- HTML <wbr> Tag
- HTML <dir> Tag