📜  HTML |<input type=”time”>(1)

📅  最后修改于: 2023-12-03 15:01:14.932000             🧑  作者: Mango

HTML | input type="time"

The input element with type="time" is used to create a time input field in a HTML form. The user can enter or select a time value, typically using a time picker interface.

Attributes

The input element with type="time" supports the following attributes:

  • name: Specifies the name of the input element.
  • value: Specifies the default value of the input element.
  • required: Specifies whether the input field is required to be filled out before submitting the form.
  • disabled: Specifies that the input field should be disabled and not be editable.
  • readonly: Specifies that the input field is read-only.
  • min: Specifies the minimum value for the input field.
  • max: Specifies the maximum value for the input field.
  • step: Specifies the stepping interval for the input field.
  • autofocus: Specifies that the input field should automatically get focus when the page loads.
Example
<label for="appointment-time">Choose a time for your appointment:</label>
<input type="time" id="appointment-time" name="appointment-time">

This will create a time input field with a label that says "Choose a time for your appointment".

Browser Support

The input element with type="time" is supported by all major browsers including Chrome, Firefox, Safari, Edge and Opera.

Summary

The input element with type="time" is a useful tool for collecting time information from users. It supports a number of useful attributes and is widely supported by all major browsers.