HTML forms: input, label and button
Building a simple form and choosing field types.
All lessons · HTML lessons: learn from scratch
A simple form
<form action="/subscribe" method="post"> <label for="email">Email</label> <input id="email" name="email" type="email" required> <label for="pw">Password</label> <input id="pw" name="pw" type="password" minlength="8" required> <button type="submit">Sign up</button> </form>
- <label for="id"> is tied to a field — clicking it focuses the field and screen readers read it.
- Without a name attribute the field value is not sent.
- required, minlength and type="email" give simple browser validation; you still need server-side checks.
Field types
The most used: text, email, password, number, date, checkbox, radio, file, tel. Use <textarea> for long text and <select> for a drop-down.