How do websites get information from you?
When you log in to Instagram, search on Google, or buy something on Amazon, you are using a Form. Forms are the primary way users interact with web applications.
Every form starts with the <form> tag. Inside it, we place elements that allow users to enter data.
The <input> tag is magical. By changing its type attribute, it transforms into different controls.
| Type | Description |
|---|---|
text |
Standard one-line text box (default). |
password |
Hides the characters (dots or asterisks). |
email |
Validates that text looks like an email on mobile keyboards. |
number |
Only allows numeric input. |
Imagine a form with 10 empty boxes and no text telling you what goes where. Nightmare, right?
The <label> tag tells the user what an input is for.
Pro Tip: Use the for attribute on the label and match it to the id of the input.
This lets you click the text to focus the input!
Great job! Ready to make sure users type the right stuff?
Next: Learn Form Validation →