HTML <form> Tag
The <form> tag is used to create an HTML form for user input.
A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A forms can also contain select menus, textarea, fieldset, legend, and label elements.
- Example Code:
<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" />
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.
- application/x-www-form-urlencoded (default)
- multipart/form-data (use this when uploading files)
method Specifies the HTTP method to use when the form is submitted.
- get (the form data is appended to the URL when submitted)
- post (the form data is not appended to the URL)
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