An HTML form with two input fields and one submit button:
![]()
The <form> tag is supported in all major browsers.
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:
An HTML form is used to pass data to a server.
Tip: The <form> element is a block-level element, and browsers create a line break before and after a form.
In XHTML, the name attribute of the <form> tag is deprecated, and will be removed. Use the id attribute instead.
DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.
| Attribute | Value | Description | DTD |
|---|---|---|---|
| action | URL | Specifies where to send the form-data when a form is submitted | STF |
| Attribute | Value | Description | DTD |
|---|---|---|---|
| accept | MIME_type | Specifies the types of files that the server accepts (that can be submitted through a file upload) | STF |
| accept-charset | character_set | Specifies a list of character encodings that the server accepts | STF |
| 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") | STF |
| method | get post |
Specifies the HTTP method to use when sending form-data | STF |
| name | name | Specifies the name of a form | TF |
| target | _blank _self _parent _top framename |
Deprecated. Specifies where to display the response that is received after submitting the form | TF |
The <form> tag supports the following standard attributes:
| Attribute | Value | Description | DTD |
|---|---|---|---|
| class | classname | Specifies a classname for an element | STF |
| dir | rtl ltr |
Specifies the text direction for the content in an element | STF |
| id | id | Specifies a unique id for an element | STF |
| lang | language_code | Specifies a language code for the content in an element | STF |
| style | style_definition | Specifies an inline style for an element | STF |
| title | text | Specifies extra information about an element | STF |
| xml:lang | language_code | Specifies a language code for the content in an element, in XHTML documents | STF |
More information about Standard Attributes.
The <form> tag supports the following event attributes:
| Attribute | Value | Description | DTD |
|---|---|---|---|
| onclick | script | Script to be run on a mouse click | STF |
| ondblclick | script | Script to be run on a mouse double-click | STF |
| onmousedown | script | Script to be run when mouse button is pressed | STF |
| onmousemove | script | Script to be run when mouse pointer moves | STF |
| onmouseout | script | Script to be run when mouse pointer moves out of an element | STF |
| onmouseover | script | Script to be run when mouse pointer moves over an element | STF |
| onmouseup | script | Script to be run when mouse button is released | STF |
| onkeydown | script | Script to be run when a key is pressed | STF |
| onkeypress | script | Script to be run when a key is pressed and released | STF |
| onkeyup | script | Script to be run when a key is released | STF |
| onreset | script | Script to be run when a form is reset | |
| onsubmit | script | Script to be run when a form is submitted |
More information about Event Attributes.
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.
Send e-mail
from a form
How to send e-mail from a form.
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
| WEB HOSTING |
|---|
| Best Web Hosting |
| PHP MySQL Hosting |
| Best Hosting Coupons |
| UK Reseller Hosting |
| Cloud Hosting |
| Top Web Hosting |
| $7.95/mo SEO Hosting |
| Premium Website Design |
| WEB BUILDING |
|---|
| Download XML Editor |
| FREE Website BUILDER |
| Free Website Templates Free CSS Templates |
| Make Your Own Website |
| W3SCHOOLS EXAMS |
|---|
|
Get Certified in: HTML, CSS, JavaScript, XML, PHP, and ASP |
| W3SCHOOLS BOOKS |
|---|
|
New Books: HTML, CSS JavaScript, and Ajax |
| STATISTICS |
|---|
|
Browser Statistics Browser OS Browser Display |
| SHARE THIS PAGE |
|---|