First name:
Last"> First name:
Last" />
Easy Tutorial
❮ Att Input Disabled Att Basefont Color ❯

HTML <form> Tag

Example

An HTML form with two input fields and a submit button:

<form action="demo_form.php" method="get">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
</form>

Browser Support

All major browsers support the <form> tag.


Tag Definition and Usage

The <form> tag is used to create an HTML form for user input.

The <form> element contains one or more of the following form elements:


Differences Between HTML 4.01 and HTML5

HTML5 introduced two new attributes: autocomplete and novalidate, and dropped some attributes supported in HTML 4.01.


Differences Between HTML and XHTML

In XHTML, the name attribute is deprecated. Use the global id attribute instead.


Attributes

Attribute Value Description
accept MIME_type Not supported in HTML5. Specifies the types of files that the server accepts (only for file upload).
accept-charset character_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.
autocomplete New on <br>off Specifies whether a form should have autocomplete on or off.
enctype application/x-www-form-urlencoded <br>multipart/form-data <br>text/plain Specifies how the form-data should be encoded before sending it to the server (for method="post").
method get <br>post Specifies the HTTP method to use when sending form-data.
name text Specifies the name of the form.
novalidate New novalidate Specifies that the form should not be validated when submitted.
target _blank <br>_self <br>_parent <br>_top Specifies where to display the response that is received after submitting the form.

Global Attributes

The <form> tag supports HTML's global attributes.


Event Attributes

The <form> tag supports HTML's event attributes.


Try It Yourself - Examples

Form with Checkboxes

Form with Radio Buttons


Related Articles

HTML Tutorial: HTML Forms and Input

HTML DOM Reference: Form Object

❮ Att Input Disabled Att Basefont Color ❯