HTML forms are used to collect user input such as names, emails, passwords, and feedback. Forms are created using the <form> element along with input controls.
<form> tag and contains form controls like <input>, <textarea>, <select>, and <button>.The <form> element wraps all form controls. It usually includes the action and method attributes.
<form action="submit.php" method="post">
<label>Name:</label>
<input type="text" name="name">
<label>Email:</label>
<input type="email" name="email">
<label>Message:</label>
<textarea name="message"></textarea>
<button type="submit">Submit</button>
</form>
| Element | Description |
|---|---|
| <form> | Defines the form container |
| <input> | Creates input fields (text, email, password, etc.) |
| <label> | Defines a label for input fields |
| <textarea> | Creates a multi-line text input |
| <select> | Creates a dropdown list |
| <button> | Submits the form |
<label> for accessibilityCreating a form in HTML involves using the <form> element along with various input controls to collect user data.
Proper form structure improves usability, accessibility, and data handling.