Module 10: HTML Forms Fundamentals
Common input Types
Choose input types that match the kind of information a field collects.
The input element supports many types. The type affects the control’s behavior, built-in validation, and the keyboard a mobile browser may offer.
<label for="email">Email</label>
<input id="email" name="email" type="email" required>
<label for="website">Website</label>
<input id="website" name="website" type="url">
<label for="start-date">Start date</label>
<input id="start-date" name="startDate" type="date">
<label for="quantity">Quantity</label>
<input id="quantity" name="quantity" type="number" min="1" max="20">
Common types include text, email, url, tel, search, password, number, date, time, checkbox, radio, file, and hidden. Do not use number for values that are identifiers rather than quantities. A postal code, account number, or one-time code should normally be text because arithmetic does not apply.
Use an email input for email addresses, but remember that browser validation is only a format check. Use tel for telephone numbers even though it does not impose one universal number format. Choose the type that helps users enter the value correctly.