Input Types
What Is It?
The type attribute changes what kind of answer an input accepts.
What the Tags Mean
text: short text.email: email format.number: a quantity.date: a date.password: hides typed characters.file: a file picker.checkboxandradio: choices.
Example 1
Save each example as index.html and open it in your browser. Each code block is a complete page.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Input Types</title>
</head>
<body>
<label for="email">Email</label>
<input id="email" type="email">
<label for="age">Age</label>
<input id="age" type="number" min="1">
</body>
</html>Browser preview
What you see: You see an email field and a number field. Browser controls can look different on different devices.
Example 2: Another Use
Use date when someone needs to choose a day.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Input Types</title>
</head>
<body>
<label for="visit">Visit date</label>
<input id="visit" type="date">
</body>
</html>Browser preview
Simple Tip
A phone number is text, not a quantity. Use type="tel" rather than type="number" for phone numbers.
Try It Yourself
Add a password field with a visible label.