Date: 12-1-24, and 12-8-24.
This chapter describes the different types for the HTML <input> element.
Here are the different input types you can use in HTML:
Tip: The default value of the type attribute is "text.
<input type="text"> defines a single-line text input field:
Note that the form itself is not visible.
Also note that the default width of a text field is 20 characters.
This is how the HTML code above will be displayed in a browser:
<input type="password"> defines a password field:
The input type="password" defines a password field:
The characters in a password field are masked (shown as asterisks or circles).
This is how the HTML code above will be displayed in a browser:
<input type="submit"> defines a button for submitting form data to a form-handler. The form-handler is typically a server page with a script for processing input data. The form-handler is specified in the form's action attribute:
The input type="submit" defines a button for submitting form data to a form-handler:
If you click "Submit", the form-data will be sent to a page called "/action_page.php".
<input type="reset"> defines a reset button that will reset all form vlaues to their default values:
The input type="reset" defines a reset button that resets all form values to their default values:
If you change the input values and then click the "Reset" button, the form-data will be reset to the default values.
This is how the HTML code above will be displayed in a browser:
If you change the input values and then click the "Reset" button, the form-data will be reset to the default values.
The <input type="tel"> is used for input fields that should contain a telephone number.
The <input type="time"> allows the user to select a time (no time zone).
Depending on browser support, a time picker can show up in the input field.
If the browser supports it, a time picker pops up when entering te input field.
Note: type="time" is not supported in Internet Explorer 11.
The <input type="url"> is used for input fields that should contain a URL address.
Depending on browser support, the url field can automatically validated when submitted.
Some smartphones recognize the url type, and adds ".com" to the keyboard to match url input.
The <input type="week"> allows the user to select a week and year.
Depending on browser support, a date picker can show up in the input field.
If the browser supports it, a date picker pops up when entering the input field.
Note: type="week" is not supported in Firefox, Safari or Internet Explorer 11.