SmartCodingTips

New Input Types in HTML5

HTML5 introduced several new input types that improve form functionality and enhance user experience by enabling appropriate keyboards and validations on different devices.

List of New Input Types

  • email – Validates that the input is a properly formatted email address.
  • url – Ensures the value is a valid URL.
  • tel – Accepts a telephone number (no automatic validation).
  • number – Accepts only numeric input with min, max, and step attributes.
  • range – Provides a slider for selecting a value within a range.
  • date – Allows users to select a date using a date picker.
  • month – Lets users choose a month and year.
  • week – Lets users select a week and year.
  • time – Allows input of a time value (hours and minutes).
  • datetime-local – Accepts both date and time without timezone.
  • color – Opens a color picker tool for selecting a color.

Example


<form>
  Email: <input type="email" name="userEmail"><br>
  URL: <input type="url" name="homepage"><br>
  Number: <input type="number" name="quantity" min="1" max="10"><br>
  Range: <input type="range" min="0" max="100"><br>
  Color: <input type="color" name="favColor"><br>
</form>