Request user data
An input field provides an interface between the browser and the user which allows data to be requested in specific ways.
The input element is multi-faceted, presenting itself to the user as: text input, radio buttons, check boxes, buttons, color pickers, dates and times, and more.
Input elements are typically placed subordinate to a form element.
- This attribute controls the appearance and functionality of the element.
- Text types:
textA single-line text field.
passwordA single-line text field whose value is obscured. Use the maxlength and minlength attributes to specify the acceptable length of the value that can be entered.
searchA field for entering search strings.
telA field for entering a telephone number.
urlA field for entering a URL.
numberA field for entering a number.
hiddenAn input area that is not displayed but whose value is submitted to the server.
- Radios and checkboxes:
radioA radio button, allowing a single value to be selected out of multiple choices.
checkboxA check box allowing single values to be selected/deselected.
- Date and time types:
dateAn input for entering a date (year, month, and day).
timeAn input for entering a time value.
datetime-localAn input for entering a date and time.
monthAn input for entering a month and year.
weekAn input for entering a date consisting of a week-number and a year.
- Single purpose types:
colorAn input for specifying a color using the browser's color picker user interface.
rangeAn input for entering an integer value between a minimum and maximum.
fileA way to let the user select a file. Use the accept attribute to define the types of files that the control can select.
- Button types:
buttonA push button with no default behavior.
resetA button that resets the contents of the form to default values.
submitA button that submits the form.
imageA graphical submit button. The src attribute defines the source of the image. The alt attribute defines alternative text. The height and width attributes define the size of the image.
- The name attribute is used as the key name in the key/value pairs submitted to the server.
- When the form is first loaded, this value is used to preset the element's display.
- When the form is submitted, this is the value that will be sent to the server.
- This attribute is used to associate a list of predefined acceptable values which have been specified with a datalist element. Provide the ID of the datalist.
- This attribute may be used to declare the input to be part of a form even when it is not directly subordinate to it. Provide the ID of the form.
- The input should be visible, but unchangable. Its value will be included in the submission.
- The input should be visible, but unchangable. Its value will not be included in the submission.
- When present, this field must not be left blank.
- Identifies this input element as the one that should receive keyboard focus when the page is loaded.
onThe browser can assist the user by automatically providing values that were previously used on similar forms.
offThe browser should not provide any automatic assistance.
nameThe browser should automatically provide the user's full name.
honorific-prefixThe browser should automatically provide the user's prefix or title, like "Dr.", "Ms.", etc.
given-nameThe browser should automatically provide the user's first name.
additional-nameThe browser should automatically provide the user's middle name.
family-nameThe browser should automatically provide the user's last name.
honorific-prefixThe browser should automatically provide the user's suffix, like "Jr.", "PhD.", etc.
nicknameThe browser should automatically provide the user's nickname.
usernameThe browser should automatically provide the user's account name.
- See the MDN documentation for more possibilities.