HTML <input> Tag
The input tag is a type of input control that allows users to add data interactively.
The <input>
element is traditionally located within the <form>
tag and may represent text fields, checkboxes, dropdowns, buttons, and other inputs by simply specifying the proper type attribute.
This tag is sometimes referred to as the <input>
element.
Syntax
Attributes
Attribute | Value | Description |
---|---|---|
accept |
file-extension
audio/* video/* image/* media-type |
Filters which file types the user may select from the file input dialogue box (only for type="file"). |
alt | text | Specifies different text for images (only when type="image" is used). |
autocomplete |
on
off |
Specifies whether autocomplete should be enabled for an element. |
autofocus | autofocus | When the page loads, this property specifies that an element should be given emphasis by default. |
checked | checked | When the website loads, an element is pre-selected (for type="checkbox" or type="radio"). |
dirname | input dirname | The text direction will be supplied, as specified. |
disabled | disabled | Specifies whether or not an element should be disabled. |
form | form-id | Specifies the form to which the element belongs. |
formaction | URL | When the form is submitted, the URL of the file that will process the input control is specified (for type="submit" and type="image"). |
formenctype |
application/x-www-form-urlencoded
multipart/form-data text/plain |
Specifies how form data should be encoded before being submitted to the server (for type="submit" and type="image"). |
formmethod |
get
post |
Defines the HTTP method for sending data to the action URL (for type="submit" and type="image") |
formnovalidate | formnovalidate | Defines that form elements should not be validated when submitted |
formtarget |
_blank
_self _parent _top framename |
Specifies where the response obtained after submitting the form should be displayed (for type="submit" and type="image"). |
height | pixels | Specifies the height of an <input> element (only for type="image") |
list | datalist_id | A element containing pre-defined choices for an <input> element. |
max |
number
date |
Specifies the highest possible value for an <input> element. |
maxlength | number | Specifies the maximum amount of characters that may be entered into an <input> element. |
min |
number
date |
Sets the minimum value for an <input> element. |
minlength | number | Specifies the minimum amount of characters that must be present in an <input> element. |
multiple | multiple | Allows a user to enter more than one value in an <input> element. |
name | text | The name of an <input> element is specified. |
pattern | regexp | Specifies a regular expression against which the value of an <input> element is tested. |
placeholder | text | Specifies a brief description of the intended value of an <input> element. |
readonly | readonly | Indicates whether an input field is read-only. |
required | required | Specifies the width of an <input> element in characters. |
size | number | Specifies the URL of the image to be used as a submit button (only when type="image" is specified). |
src | URL | Specifies the URL of the image to use as a submit button (only for type="image") |
step |
number
any |
Specifies the range of legal numbers in an input field. |
type |
button
checkbox color date datetime-local file hidden image month number password radio range reset search submit tel text time url week |
Specifies the kind of <input> element that will be shown. |
value | text | The value of an <input> element is specified. |
width | pixels | Specifies the width of an <input> element (only for type="image") |
Supported Browsers
Element | Chrome | Firefox | Safari | Edge / IE | Opera |
---|---|---|---|---|---|
<input> | Yes | Yes | Yes | Yes | Yes |