Forms
form groups input fields together. Every input should have an associated label. A button with type="submit" submits the form.
Example
<form>
<label for="name">Name</label>
<input type="text" id="name" name="name">
<br>
<button type="submit">Submit</button>
</form>
▶ Try it in the editor Task
Add another field for an email address (type="email") with a matching label.
Related tools
HTML Form Generator
Add text, email, phone, password, select, checkbox or radio fields and get ready HTML form code with proper labels and built-in validation.
The <form> tag
The action, method, and enctype attributes of the <form> tag, with an example.
The <input> tag
Types and attributes of the <input> tag: type, name, value, required, pattern.
The <label> tag
The for attribute of <label>, linking a caption to an input.
Build a contact form
Practice exercise: build a contact form with name, email, and message fields.
Build a registration form with built-in validation
Practice exercise: build a course sign-up form with fieldset, input types, required, pattern and minlength — validation without JavaScript.
Build a login form
Practice exercise: fix a broken sign-in form — email and password with autocomplete for password managers, remember me and a forgot-password link.