Input Control Elements
suggest changeIntroduction
A key component of interactive web systems, input tags are HTML elements designed to take a specific form of input from users. Different types of input elements can regulate the data entered to fit a specified format and provide security to password entry.
Syntax
<input type="" name="" value="">
Parameters
Parameter | Details |
——— | —–– |
class | Indicates the Class of the input|
id | Indicates the ID of the input |
type | Identifies the type of input control to display. Acceptable values are hidden
, text
, tel
, url
, email
, password
, date
, time
, number
, range
, color
, checkbox
, radio
, file
, submit
, image
, reset
, and button
. Defaults to text
if not specified, if the value is invalid, or if the browser does not support the type specified. |
name | Indicates the name of the input|
disabled | Boolean value that indicates the input should be disabled. Disabled controls cannot be edited, are not sent on form submission, and cannot receive focus. |
checked | When the value of the type attribute is radio or checkbox, the presence of this Boolean attribute indicates that the control is selected by default; otherwise it is ignored. |
multiple | HTML5 Indicates multiple files or values can be passed (Applies only to file
and email
type inputs ) |
placeholder | HTML5 A hint to the user of what can be entered in the control . The placeholder text must not contain carriage returns or line-feeds |
autocomplete | HTML5 Indicates whether the value of the control can be automatically completed by the browser. |
readonly | Boolean value that indicates the input is not editable. Readonly controls are still sent on form submission, but will not receive focus. HTML5: This attribute is ignored when the value of type
attribute is either set to hidden
, range
, color
, checkbox
, radio
, file
or button
.|
required | HTML5 Indicates a value must be present or the element must be checked in order for the form to be submitted |
alt | An alternative text for images, in case they are not displayed.
autofocus | The <input>
element should get the focus when page loads.
value | Specifies the value of <input>
element.
step | The step
attribute specifies the legal number intervals. It works with the following input types: number
, range
, date
, datetime-local
, month
, time
and week
.
Remarks
As with other HTML5 void elements, <input>
is self-closing and may be written <input />
. HTML5 does not require this slash.
The following are valid input types in HTML:
The following are newly introduced input types as a part of HTML 5 standard. Some of these types are not supported by all web browsers. In the case where a type is not supported, the input element will default to the text
type.
color
date
datetime
(Deprecated and Obsolete)datetime-local
email
month
number
range
search
tel
time
url
week
To check which browsers support which types, you can go to caniuse.com.