iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

HTML Input Types

The type attribute on <input> chooses the kind of input and the on-screen keyboard the browser shows. Picking the right type gives users hints and free validation.

Input types

typePurposeMobile keyboard
textDefault single-line input.Letters
emailEmail address. Validated for format.Adds @
passwordText is masked.Letters
numberNumeric input. Spinner buttons appear.Number pad
telPhone number. No format validation.Phone pad
urlFull URL. Validated.Adds /, .com
searchSearch query. Many browsers add a clear button.Letters
date / time / datetime-localPicker UI for dates and times.Date picker
colorColor picker.
rangeSlider, not displayed as a number.
checkboxSingle on/off.
radioOne of several mutually exclusive choices (same name).
fileFile upload. Add multiple for many files.
hiddenValue submitted without being visible.
submit / resetButtons. Prefer <button> instead.
Tip: Always pick a specific type. Using type="email" instead of type="text" for an email field gives you free format validation and a friendlier keyboard on phones.

Example

Example
<!DOCTYPE html>
<html>
<head>
    <title>HTML Input Types</title>
</head>
<body>

<h1>HTML Input Types</h1>
<p>This is a demo page for the "HTML Input Types" lesson.</p>

</body>
</html>
Try it Yourself »

Exercise

Use the input type that shows a date picker.

<input type=" ">

Test yourself

Q1. Mobile gets a numeric keyboard for…
Q2. A date picker uses…
Q3. A password field uses…

Discussion

Loading…