Note/Warning/Info
Using HTML, you can create the Forms but you cannot process the Form using HTML. To process the Form, you must use a programming language like Java, PHP, Python etc.
HTML <form> tag
Form helps to collect information about user who visits your website.
For example – Login form where user can provide their personal details like Name, Email id, Phone number and other contact information.
You can add fields like Radio buttons, Submit buttons, checkboxes, textarea, etc in the form.
Click Here to learn about HTML Forms with multiple examples.
It is always better to style the HTML forms. To style forms, master CSS Forms.
Syntax:
<form action=”URL” method=”postname.php”> … </form>
Example
<form> First Name: <input type="text" name="firstname"/> <br/> <br/> Last Name: <input type="text" name="lastname"/> </form>
Default value
display: block;
How Browser will display
BLOCK Level.
Difference between HTML4.01, XHTML and HTML5
HTML4 | XHTML | HTML5 |
---|---|---|
NA | XHTML uses id attribute instead of name attribute | HTML5 contains new attributes like autocomplete, novalidate etc. Here, the accept attribute is deprecated. |
Attributes used with <form> tag
Attribute | Description |
---|---|
target | This decides where the user will see the response or message once he/she submits the form. It can take any one ot these values - |
accept-charset | Defines the list of Character set (Character encodings) that the server accepts for processing. |
action | Once the user provides the information in the HTML form, you need to send this data to server to process them. The 'action' attribute sets the path/URL which will be a separate page which will process the information. |
autocomplete | Sets whether the form will have the autocomplete on or off. It is added in HTML5. It can take the values as either on or off. |
enctype | Defines how to encode the form data before sending it to the server. The method="post" uses this. It can accept these values - |
formaction | Once the user submits the form, this attribute decides where to send the form data using a URL/path. This path is linked to another page which will process the user data. |
method | It decides whether to use the HTTP get method or the HTTP post method while sending the data from the form. |
name | When you code the 'name' attribute on the form, it sets the name of the form. When you code this attribute on an element, then it sets the name of that particular element. |
novalidate | It tells the browser not to validate the form when the user sbmits it. This is a boolean value which can be eithter true or false. It is added in HTML5. |
accept | It contains comma seperated list of file types and the server accepts this file (HTML5 does not support this attribute). |
Global Attributes
The <form> tag supports Global attributes.
Event Attributes
The <form> tag supports Event attributes.
Supporting Browsers

Related Tags
<input>, <datalist>, <keygen>, <output>, <textarea>, <label>, <legend>, <fieldset> , <button>, <select> & <option> tags.