HTML form Tag

HTML <form> Tag: The HTML form tag is used to create an HTML form.  And there are many elements which are used within form tag. For example: <input>, <textarea>, <button>, <select>, <option>, <optgroup>, <fieldset>, <label>. HTML 4.01 does not support autocomplete and novalidate.

 HTML<form>Tag

This HTML<form>tag supports both the global and the event attributes. Two new attributes added autocomplete and novalidate, and accept attribute is removed in HTML 5.

Syntax: <form> Text </form>

Browser compatibility

The HTML<form> tag is supported by different types of browsers.

  • Chrome
  • Firefox
  • Opera
  • Safari
  • Internet Explorer.

Example:

<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
First name: <input type="text" name="FirstName" value="Freshersnow"><br>
Last name: <input type="text" name="LastName" value="Tutorials"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Output:

html form tag

Attributes that are supported by the <form> tag

Attribute Value Description
accept file_type Specifies a comma-separated list of file types that the server accepts
accept-charset charachter_set Specifies the character encodings that are to be used for the form submission
action URL Specifies where to send the form-data when a form is submitted
enctype application/x-www-form-url encoded Specifies how the form-data should be encoded when submitting it to the server
method get
post
Specifies the HTTP method to use when sending form-data
name text Specifies the name of a form
target _blank
_self
_parent
_top
Specifies where to display the response that is received after submitting the form