Sobes.tech
Intern

What types of input elements are there in HTML?

sobes.tech AI

Answer from AI

There are the following types of input elements:

  • text: Single-line text field.
  • password: Password input field, characters are hidden.
  • submit: Button to submit the form.
  • reset: Button to reset the form.
  • radio: Radio button (one of many).
  • checkbox: Checkbox (one or multiple from a set).
  • button: Regular button.
  • file: File selection field.
  • hidden: Hidden field, not visible to the user but sent with the form.
  • image: Image button to submit the form.

HTML5 specification added new types:

  • email: Email address input field.
  • url: URL input field.
  • number: Number input field.
  • range: Slider to select a numeric value within a range.
  • date: Date picker.
  • month: Month and year picker.
  • week: Week and year picker.
  • time: Time picker.
  • datetime-local: Date and time picker without timezone.
  • search: Search field.
  • color: Color picker.
  • tel: Telephone number input.

Example usage:

<!-- Single-line text field -->
<input type="text" placeholder="Name">

<!-- Password input field -->
<input type="password" placeholder="Password">

<!-- Submit button -->
<input type="submit" value="Send">

<!-- Reset button -->
<input type="reset" value="Reset">

<!-- Radio buttons -->
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female

<!-- Checkboxes -->
<input type="checkbox" name="interests" value="music"> Music
<input type="checkbox" name="interests" value="sports"> Sports

<!-- Regular button -->
<input type="button" value="Click me">

<!-- File selection field -->
<input type="file">

<!-- Hidden field -->
<input type="hidden" name="userId" value="123">

<!-- Image button -->
<input type="image" src="submit.png" alt="Send">

<!-- Email field -->
<input type="email" placeholder="Email">

<!-- URL field -->
<input type="url" placeholder="Website">

<!-- Number field -->
<input type="number" min="1" max="10">

<!-- Slider -->
<input type="range" min="0" max="100">

<!-- Date field -->
<input type="date">

<!-- Month field -->
<input type="month">

<!-- Week field -->
<input type="week">

<!-- Time field -->
<input type="time">

<!-- Date and time (local) -->
<input type="datetime-local">

<!-- Search field -->
<input type="search" placeholder="Search">

<!-- Color picker -->
<input type="color">

<!-- Phone number field -->
<input type="tel" placeholder="+7 (xxx) xxx-xx-xx">