-
Hajipur, Bihar, 844101
HTML offers many input types that help you collect specific kinds of data from users. Each input type tells the browser what kind of value is expected, which improves accuracy and makes forms easier to use. In this chapter, you will learn about all important input types, how they work and when you should use them.
Input types are values assigned to the type attribute inside an <input> tag. Based on the input type, the browser decides how the field should behave. For example, a text field accepts letters, a number field accepts digits, a date field shows a date picker and so on. These types make your forms more user friendly and help avoid wrong entries.
The text input is the most basic field. It accepts plain text such as names, usernames and general information.
<input type="text" name="fullname" placeholder="Enter your name">
A password input hides the characters typed by the user. It displays dots instead of letters for privacy.
<input type="password" name="password" placeholder="Enter password">
The email type checks if the entered text follows the correct email format. Some mobile browsers also show an email-friendly keyboard.
<input type="email" name="email">
A number field accepts only digits. It also shows small arrows that let users increase or decrease the value.
<input type="number" name="age" min="1" max="100">
The tel type accepts phone numbers. It does not validate formats automatically, but on mobile devices it shows a numeric keypad.
<input type="tel" name="phone">
The URL input checks if the entered value follows a proper web address format.
<input type="url" name="website">
The search type works like a text field but is designed for search bars. Some browsers add a clear (X) button inside it.
<input type="search" name="query">
The date input shows a date picker, making it easy to select a day without typing.
<input type="date" name="dob">
The time input allows the user to select time in hours and minutes.
<input type="time" name="appttime">
This type allows selecting both date and time together in a single control.
<input type="datetime-local" name="meeting">
The month type is ideal for selecting month and year, such as billing cycles or subscription periods.
<input type="month" name="billing">
This type lets users select a specific week of the year.
<input type="week" name="weeknumber">
Radio buttons allow users to pick only one option from a list. Buttons with the same name belong to the same group.
<input type="radio" name="gender" value="female"> Female
<input type="radio" name="gender" value="male"> Male
Checkboxes allow multiple selections. They are used for hobbies, skills and similar choices.
<input type="checkbox" name="skill" value="html"> HTML
<input type="checkbox" name="skill" value="css"> CSS
The file type lets users upload files from their device, such as images, PDFs or documents.
<input type="file" name="resume">
A range control creates a slider. It is useful for ratings, volume controls and similar elements.
<input type="range" name="volume" min="0" max="100">
The color input opens a color picker tool, allowing users to select a colour.
<input type="color" name="favcolor">
A hidden input is not visible, but it sends important backend data when the form is submitted.
<input type="hidden" name="userid" value="1001">
The submit button sends the form data to the server.
<input type="submit" value="Submit">
A reset button clears all fields in a form.
<input type="reset" value="Clear">
A button input works like a regular button and is usually used with JavaScript for custom actions.
<input type="button" value="Click Me">
The image input allows you to use an image as a submit button.
<input type="image" src="submit.png" width="100">
Here is a small form that uses a mix of input types.
<form>
<input type="text" placeholder="Name">
<input type="email" placeholder="Email">
<input type="number" placeholder="Age">
<input type="date">
<input type="color">
<input type="file">
<input type="submit" value="Send">
</form>
Input types make forms flexible and user friendly. You learned how text, email, password, number, date, time, radio, checkbox, file, range, color, hidden and many other input types work. Each of them serves a different purpose and improves the accuracy of the data users enter. Once you understand these types, you can design better forms that match your website’s needs.
Q1. Create a form with text, email, and password fields.
Q2. Add a file upload option with <input type="file">.
Q3. Create radio buttons for gender selection.
Q4. Use a range slider to select volume between 0 to 100.
Q5. Use a color picker to select a background color.
Q6. Include a date picker for selecting DOB.
Q7. Add a time and datetime-local input for scheduling.
Q8. Use tel input with a placeholder for format guidance.
Q9. Add a reset button that clears the form.
Q10. Create a hidden input to pass a user ID value.