HTML - <form> Tag



The HTML <form> tag is used for creating a form for user input. A form can contain textfields, checkboxes, radio-buttons and more. Forms are used to pass user-data to a specified URL.


Live Demo
<!DOCTYPE html>

      <title>HTML form Tag</title>

      <form action = "/cgi-bin/hello_get.cgi" method = "get">
         First name: 
            <input type = "text" name = "first_name" value = "" maxlength = "100" />
         <br />
         Last name: 
            <input type = "text" name = "last_name" value = "" maxlength = "100" />
         <input type = "submit" value ="Submit" />


This will produce the following result −

Global Attributes

This tag supports all the global attributes described in HTML Attribute Reference

Specific Attributes

The HTML <form> tag also supports the following additional attributes −

Attribute Value Description
accept MIME_type Specifies a comma-separated list of content types that the server accepts.
accept-charset charset list Specifies a list of character encodings that the server accepts. The default value is "unknown".
action URL Specifies a URI/URL of the back-end script that will process the form
autocompletehtml-5 on
Specifies whether form should have autocomplete on or off
enctype mimetypes The mime type used to encode the content of the form.
method get
Specifies the HTTP method to use when the form is submitted. Possible values −
  • get (the form data is appended to the URL when submitted)
  • post (the form data is not appended to the URL)
name form name Defines a unique name for the form.
novalidate html-5 novalidate Specifies that the form should not be validated when submitted.
target _blank

Target to open the given URL.

_blank − the target URL will open in a new window.

_self − the target URL will open in the same frame as it was clicked.

_parent − the target URL will open in the parent frameset.

_top − the target URL will open in the full body of the window.

Event Attributes

This tag supports all the event attributes described in HTML Events Reference

Browser Support

Chrome Firefox IE Opera Safari Android
Yes Yes Yes Yes Yes Yes