HTML <form>
Published Jul 1, 2022
Contribute to Docs
The <form> element represents an interface to collect and submit user supplied information. This can include open-ended text inputs, radio buttons, calendar information, and more.
Syntax
<form>
<!-- Form content lives here -->
</form>
The opening and closing <form> tags wrap around many other elements to create the form.
Attributes
Common attributes of the <form> element are shown below:
| Attribute | Data Type | Description |
|---|---|---|
action |
String | Specifies the URL to send the form data to. |
method |
String | Specifies the HTTP verb used when submitting the form. Examples include:
|
autocomplete |
Boolean | Specifies if the browser autocomplete feature should be available in this form. |
Example
Suppose that Codecademy needs a form, with required inputs, for visitors to create a new account. Here is one possible way to build it:
<html><head> </head><body><h1>Sign up for a new Codecademy account</h1><!-- This form will send the email and password to https://codecademy.com/sign-up using a POST request --><form action="https://codecademy.com/sign-up" method="POST"><label>Email Address</label><input name="user_email" type="email" required /><label>Password</label><input name="user_password" type="password" required /><!-- Clicking a button with type submit will submit the form it is inside of --><button type="submit">Submit</button></form></body></html>

Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn HTML on Codecademy
- Front-end engineers work closely with designers to make websites beautiful, functional, and fast.
- Includes 34 Courses
- With Professional Certification
- Beginner Friendly.115 hours
- Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
- Beginner Friendly.7 hours