HTML Form Tag
- Purpose: To collect user input from visitors to a website. This input can then be processed and used for various purposes, such as:
- Signing up for a newsletter
- Making a purchase
- Submitting a contact form
- Logging into an account
- Tags: <form>
- Common Form Elements:
- <input>: This is the most versatile element, used for various input types:
- text: For single-line text input (e.g., names, usernames)
- password: For password input (masked for security)
- email: For email addresses
- number: For numerical input
- date: For date input
- radio: For selecting one option from a group
- checkbox: For selecting multiple options from a group
- file: For uploading files
- submit: Creates a submit button to send the form data
- reset: Creates a button to reset the form fields
- <textarea>: For multi-line text input (e.g., messages, comments
- <select>: For creating dropdown lists or option menus
- <option>: Used within <select> to define individual options
- <label>: Associates a label with a form control (e.g., a label for a text input field).
- <input>: This is the most versatile element, used for various input types:
- Example:
<form> <label for="name">Name:</label><br> <input type="text" id="name" name="name"><br><br> <label for="email">Email:</label><br> <input type="email" id="email" name="email"><br><br> <input type="submit" value="Submit"> </form>
This code creates a simple form with two input fields: one for the user’s name and one for their email address.