HTML provides various input types that allow users to enter different types of data. Some commonly used HTML input types are:
- Text input: This input type is used for accepting a single line of text.
Example:
<input type="text" name="username">
- Password input: This input type is used for accepting a password or other sensitive information.
Example:
<input type="password" name="password">
- Checkbox input: This input type is used for accepting boolean values (true or false) as input.
Example:
<input type="checkbox" name="remember_me" value="true">
- Radio button input: This input type is used for presenting a set of mutually exclusive options.
Example:
<label for="option1">Option 1</label>
<input type="radio" id="option1" name="option" value="1">
<label for="option2">Option 2</label>
<input type="radio" id="option2" name="option" value="2">
- File input: This input type is used for uploading files from the user’s computer.
Example:
<input type="file" name="avatar">
- Submit button input: This input type is used for submitting a form to the server.
Example:
<input type="submit" value="Submit">
- Reset button input: This input type is used for resetting the values of a form to their default values.
Example:
<input type="reset" value="Reset">
- Hidden input: This input type is used for storing data that is not meant to be displayed to the user.
Example:
<input type="hidden" name="csrf_token" value="abcdef123456">
- Select input: This input type is used for presenting a dropdown menu of options.
Example:
<select name="country">
<option value="USA">United States</option>
<option value="CAN">Canada</option>
<option value="MEX">Mexico</option>
</select>
- Textarea input: This input type is used for accepting multiple lines of text.
Example:
<textarea name="message"></textarea>
- Range input: This input type is used for accepting a numeric value within a specified range.
Example:
<input type="range" name="age" min="18" max="65" value="25">
- Date and time input: These input types are used for accepting dates and times.
Example:
<input type="date" name="dob">
<input type="time" name="time">
<input type="datetime-local" name="meeting_time">