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.


  <!-- Form content lives here -->

The opening and closing <form> tags wrap around many other elements to create the form.


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:
  • GET
  • POST
  • PUT
autocomplete Boolean Specifies if the browser autocomplete feature should be available in this form.


Suppose that Codecademy needs a form, with required inputs, for visitors to create a new account. Here is one possible way to build it:

<head> </head>
<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 />
<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>

Output of the example above for form tag

All contributors

Looking to contribute?

Learn HTML on Codecademy