HTML input types are essential for creating interactive and user-friendly web forms. They allow developers to specify the kind of data that a user can enter into a form. From simple text fields to advanced input options like date pickers and file uploads, HTML input types enhance the functionality and usability of web applications.
text
- For single-line text input.password
- For password input where characters are masked.email
- For email addresses.number
- For numeric input with optional min, max, and step attributes.tel
- For telephone numbers.url
- For URLs.search
- For search input.date
- For date input (year, month, and day).datetime-local
- For date and time input without timezone.month
- For selecting a month and year.week
- For selecting a specific week of the year.time
- For time input.color
- For color input via a color picker.checkbox
- For selecting one or more options.radio
- For selecting a single option from a group.file
- For file uploads.range
- For selecting a numeric value within a range using a slider.hidden
- For hidden input that is not visible to the user.submit
- For submitting the form data.reset
- For resetting the form fields to their default values.button
- For clickable buttons.image
- For graphical submit buttons.<input type="text" name="username" placeholder="Enter your name">
<input type="email" name="email" placeholder="Enter your email">
<input type="password" name="password" placeholder="Enter your password">
<input type="checkbox" name="subscribe" value="newsletter"> Subscribe to Newsletter
<input type="radio" name="gender" value="male"> Male <input type="radio" name="gender" value="female"> Female
<input type="date" name="dob">
<input type="file" name="profile_picture">
Explore some advanced input types below:
<input type="color" name="favorite_color">
<input type="range" name="volume" min="0" max="100">
<input type="search" name="query" placeholder="Search here">
Below is an example form that uses various input types:
<form action="/submit" method="post"> <label for="name">Name:</label> <input type="text" id="name" name="name" placeholder="Your Name"> <label for="email">Email:</label> <input type="email" id="email" name="email" placeholder="Your Email"> <label for="password">Password:</label> <input type="password" id="password" name="password"> <label for="dob">Date of Birth:</label> <input type="date" id="dob" name="dob"> <input type="submit" value="Submit"> </form>
A: Input types define the type of data a user can input in a form field.
A: HTML offers over 20 input types, including text, email, password, radio, and file.
A: Yes, CSS can be used to style input types to match your design needs.
Follow these steps to create a simple login form:
<form action="/login" method="post"> <label for="username">Username:</label> <input type="text" id="username" name="username"> <label for="password">Password:</label> <input type="password" id="password" name="password"> <input type="submit" value="Login"> </form>