HTML <input> tag
HTML <input> tag
The <input>
tag creates form fields that accept single-line user input.
The <input>
elements can be presented many different ways, including simple text fields, buttons, checkboxes, drop-down menus, etc. Please refer the type
attribute in the following table.
Example
Attributes
The following are the attributes of <input> tag. Also try Global attributes.
Attribute | Value | Explanation |
---|---|---|
accept |
| Specifies the types of files that need to be filtered out from the file input dialog box so that the user can easily pick one. Applicable only it type = "file". |
alt | text | Specifies an alternate text for image. Appicable only with type = "image" |
autocomplete |
| Specifies whether the value of the <input> element can be automatically completed by the browser. |
autofocus | - | Specifies that an <input> element should automatically get focus when the page loads. |
checked | - | Specifies that an <input> element should be pre-selected when the page loads. |
dirname | fileName.dir | Specifies that the text direction of the <input> element will be submitted. |
disabled | - | Specifies that the <input> element is not available for user interaction. |
form | form_id | Specifies that <input> element declared outside <form> element is associated with it. |
formaction | URL | Specifies where to send a form data when the user clicks on the submit button. |
formenctype |
| Specifies how to encode a form-data before sending it to a server. |
formmethod |
| Specifies the HTTP method that the browser uses to submit the form. |
formnovalidate | - | Specifies that the <input> elements within the form should not be validated when submitted. |
formtarget |
| Specifies where to display the response that is received after submitting the form. |
height | px | Specifies the height of the <input> element. Applicable only if, type = "image". |
list | datalist_id | Provides pre-defined options to suggest to the user. |
max |
| Specifies a maximum value for an <input> element. |
maxlength | number | Specifies the maximum number of characters that the user can enter into the <input> element. |
min |
| Specifies a minimum value for an <input> element. |
minlength | number | Specifies the minimum number of characters that the user should enter into the <input> element. |
multiple | - | Specifies that the user can enter more than one value. |
name | text | Specifies the name of the <input> field. |
pattern | regexp | Specifies a regular expression that an <input> element's value is validated against. |
placeholder | text | Provides a hint to the user of what can be entered in the <input> element. |
readonly | - | Specifies that the user cannot modify the value of the <input>. |
required | - | Specifies that the <input> field is mandatory and it must be filled before submitting a form. |
size | number | Specifies the width of the input field. |
src | URL | Specifies the location of the image. Applicable only if type = "image". |
step | number | Specifies the n step increment. Applicable only if type = "number". |
type |
| Specifies the type of <input> element to display. |
value | text | Specifies the initial value of an <input> element. |
width | px | Specifies the width of the image. Applicable only if, type = "image". |
Deprecated Attributes
The following attribute should not be used in any case.
Attribute | Value | Explanation |
---|---|---|
align |
| Specifies the alignment of the <input> tag. Used only with <input type="image">. |
Reminder
Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in HTML.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.