Forms & User Input · 9 min read · Beginner
Accessible HTML Forms
Build user-friendly forms with explicit labels, appropriate input types, and native browser validation.
What you'll learn
- Connect <label> elements to inputs using for and id
- Use semantic input types (email, url, number) for better mobile keyboards
- Leverage native HTML validation attributes like required and minlength
Forms are how users sign up, search, and interact with your site. Well-built HTML forms give you accessibility, mobile keyboard optimization, and validation for free.
Always Pair <label> with <input>
Never rely on placeholder text as a replacement for a <label>. Placeholders disappear as soon as the user starts typing and are harder to read.
Try It Yourself
Try submitting the form empty or with an invalid email to see native browser validation in action:
Accessible Signup Form
Live Result
Console Output
No console output yet. Try calling console.log(...) in JS.
Check Your Understanding
Score: 0 / 1
1. How do you explicitly associate a <label> with an <input>?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.