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.
It is always better to style the HTML forms. To style forms, master CSS Forms.
<form action=”URL” method=”postname.php”> … </form>
How Browser will display
Difference between HTML4.01, XHTML and 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
|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).
The <form> tag supports Global attributes.
The <form> tag supports Event attributes.
<input>, <datalist>, <keygen>, <output>, <textarea>, <label>, <legend>, <fieldset> , <button>, <select> & <option> tags.