HTML form tag

## HTML Reference

HTML by Alphabet HTML by Function HTML Global Attributes HTML Events HTML Canvas HTML Audio/Video HTML Doctypes HTML Colornames HTML Colorpicker HTML Colormixer HTML Character Sets HTML ASCII HTML ISO-8859-1 HTML Symbols HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods Keyboard Shortcuts

## HTML Tags

<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <command> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <keygen> <label> <legend> <li> <link> <map> <mark> <menu> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <table> <tbody> <td> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

# HTML <form> Tag

« HTML Reference
<frame> Tag »

## Example

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

<form action="demo_form.asp" method="get">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
Try it yourself »
(more examples at the bottom of this page)

## Browser Support

The <form> tag is supported in all major browsers.

## Definition and Usage

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

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

- <input>
- <textarea>
- <button>
- <select>
- <option>
- <optgroup>
- <fieldset>
- <label>

## Differences Between HTML 4.01 and HTML5

HTML5 has added two new attributes: autocomplete and novalidate, and removed the accept attribute.

## Differences Between HTML and XHTML

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

## Attributes

New : New in HTML5.

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

## Global Attributes

The <form> tag also supports the Global Attributes in HTML.

## Event Attributes

The <form> tag also supports the Event Attributes in HTML.

## Try it Yourself - Examples

Form with checkboxes
A form with two checkboxes, and a submit button.

Form with radiobuttons
A form with two radio buttons, and a submit button.

## Related Pages

HTML tutorial: HTML Forms and Input

HTML DOM reference: Form object

« HTML Reference
<frame> Tag »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE