<form>: The HTML Form Element
1 Description
The HTML form element exists to allow users a way to input information into a web page and submit that information to a web server.
Some common uses of HTML forms are...
- To allow users to submit login credentials (an email or username and a password) to a web server so that they may login to a website.
- To allow users to input billing and shipping information when making an online purchase.
- To input a search query or term to a website and be provided search results from the web server.
Contained within the <form>
element are (usually) one or more <input>
elements,
<label>
elements, and <button>
elements.
The <input>
elements allow users to input text, numbers, <select>
from one or more <option>
elements in a dropdown menu, and more. <label>
elements provide a name for different <input>
elements, and <button>
elements are typically used to submit the information in the html <form>
to a web server or
to reset the form to it's beginning state.
1.1 See Also
The following elements, because they are related to <form>
elements.
- The
<label>
element - The
<form>
element - The
<fieldset>
element - The
<button>
element
2 Examples
<!DOCTYPE html>
<html>
<head>
<title>Example Page</title>
</head>
<body>
<form action="/api/account/login" method="POST">
<h1>Login</h1>
<label for="username">Username</label>
<input type="text" id="username" name="username" placeholder="Username" required/>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Password" required/>
<button type="submit">Login</button>
</form>
</body>
</html>
This document was last updated: