HTML Basics
HTML Forms
Forms collect information from users, such as logins, searches, and sign-ups. This page covers the form element and the most common input controls.
The Form Element
The <form> element wraps input controls. Its action attribute says where to send the data, and method says how (GET or POST).
<form action="/submit" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Send</button>
</form>Common Input Types
| Type | Use |
|---|---|
| text | Single line of plain text |
| Email address with built-in validation | |
| password | Hidden text for passwords |
| number | Numeric input with optional min and max |
| checkbox | One or more on/off options |
| radio | Choose one option from a group |
| date | A date picker |
Other Controls
<textarea name="message" rows="4"></textarea>
<select name="city">
<option value="pune">Pune</option>
<option value="mumbai">Mumbai</option>
</select>💡
Always pair each input with a <label> and match the label's for attribute to the input's id. This helps screen readers and lets users click the label to focus the field.
