The HTML <form> tag is used for declaring a form, allowing user-inputted data to be sent somewhere.
The <form> tag is used in conjunction with form-associated elements such as:
Required Attributes
- action is used to specify where the form is sent to. It must take the form of a URI.
Optional Attributes
- method can be used to specify how the form is sent. The value must be get (default), which bolts the form values onto the URI or post which invisibly sends the form data in the body of the HTTP request.
- enctype can be used to specify the MIME type used to encode the form data. The default value is application/x-www-form-urlencoded, but this should be multipart/form-data when the form contains a file input element.
- accept can be used to specify which file-types (selected from a file input element) should be accepted. This is a comma-separated list of MIME types.
- accept-charset can be used to specify which character sets should be accepted. This is a comma-separated list.
- Common attributes
Example
<form action="/folder/scriptfile.php" method="post">
<fieldset>
<legend> Address </legend>
<label>Address Line 1</label>
<input name="adressLine1" />
</fieldset>
<div><input type="submit" /></div>
</form>
Changes in HTML5
Related Tags