HTML Forms
HTML forms are used to collect user input. The form element acts as a container for various types of input elements like text fields, checkboxes, radio buttons, and submit buttons.
Example:
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Submit">
</form>
HTML Input Types
HTML provides various types of input fields, each serving a different purpose:
text
: Single-line text inputemail
: Email input with validationpassword
: Password input with hidden characterscheckbox
: Checkbox inputradio
: Radio button inputsubmit
: Button to submit the form
Try It Yourself
Quiz: Test Your Knowledge
Which input type is used to create a password field?
Coding Challenge
Create a form that collects the user's first name, last name, email address, and includes a dropdown for selecting their country. Add a submit button at the end of the form using the code editor above.