HTML <form> Tag
Description
The <form>
HTML element sets the form on the web page. The form is intended for data exchange between the user and the server. The scope of the forms is not limited to sending data to the server, using client scripts you can access any element of the form, change it and apply it as you wish.
A document can contain any number of forms, but only one form can be sent to the server at a time. For this reason, these forms must be independent of each other.
Properties
- Permitted Parents
- Any element that accepts flow content
- Content
- Block, inline, and text, but not containing <form> elements
- Start/End Tags
- Start tag: required, End tag: required
Example
<form action="" method="post">
First name: <input type="text" name="first_name" /><br />
Last name: <input type="text" name="last_name" /><br />
<input type="submit" value="Submit" />
</form>
Attributes
Attribute | Definition |
---|---|
accept-charset | Specifies a list of character encodings that the server accepts. |
action | Specifies a URI/URL of the page that will process the form. |
autocomplete | Specifies whether a form should have autocomplete on or off |
enctype | Specifies the content type used to encode the
form data set when it's submitted to the server. Possible values:
|
method | Specifies the HTTP method to use when the form
is submitted. Possible values:
|
name | Assigns a name to the form. This is used when referencing the form with stylesheets or scripts. If there are multiple forms, the name of each form must be unique. |
novalidate | Specifies that the form should not be validated when submitted |
target | Specifies where to open the action URL.
|
Global Attributes
The <form>
tag also supports the Global Attributes in HTML5
Event Attributes
The <form>
tag also supports the Event Attributes in HTML5
Browser Support
The following table will show you the current browser support for the HTML <form>
tag.
Desktop | |||||
12 | 1 | 1 | 15 | 4 |
Tablets / Mobile | |||||
18 | 4 | 14 | 3.2 | 1 | 4.4 |
Last updated by CSSPortal on: 30th March 2024