English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML <input> tag is an interactive control that provides users with input controls for entering data. Traditionally, the <input> tag is located within the <form> tag and can be used to represent text fields, checkboxes, dropdown menus, buttons, and other inputs by setting the appropriate type attribute. This tag is also commonly referred to as the <input> element.
A simple HTML form that includes two text input fields and a submit button:
!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML5 Usage of footer tag (Basic Tutorial Website oldtoolbag.com)</title>/title> </head> <body> <h1>oldtoolbag.com basic tutorial</h1> <form action="demo-form.php" method="post"> Company: <input type="text" name="company"><br> Address: <input type="text" name="address"><br> <input type="submit" value="Submit"> </form> </body> </html>Test and see ‹/›
In this HTML5In the document example, we used the <form> tag to create an HTML form. This form includes two <input> controls for company and address, and one <input> control for the submit button.
IEFirefoxOperaChromeSafari
Most browsers support the <input> tag.
The <input> tag specifies the input field where users can enter data.
The <input> element is used within the <form> element to declare input controls that allow users to enter data.
By setting the type attribute, the <input> element can become a text field, checkbox, radio button, dropdown menu, button, password field, and more!
Note: The <input> element is empty, it only contains label attributes.
Hint: You can use <label> An element to define the annotation of the <input> element.
In HTML 4.01 In, "align" data is no longer used. HTML5 Does not support this attribute. CSS can be used to define the alignment of the <input> element.
In HTML5In, <input> added several attributes and corresponding values.
In HTML, the <input> tag does not have a closing tag.
In XHTML, the <input> tag must be closed correctly.
New : HTML5New tag.
Attribute | Value | Description |
---|---|---|
accept | audio/* video/* image/*MIME_type | Specifies the type of file to be submitted via file upload. (Only for type="file") |
align | left right top middle bottom | HTML5Deprecated, not recommended for use. Specifies the alignment of image inputs. (Only for type="image") |
alt | text | Defines alternative text for image inputs. (Only for type="image") |
autocompleteHTML5 | on off | The autocomplete attribute specifies whether the automatic completion feature should be enabled for the input field of the <input> element. |
autofocusHTML5 | autofocus | The attribute specifies that the <input> element should automatically gain focus when the page is loaded. |
checked | checked | The checked attribute specifies that the <input> element should be pre-selected when the page is loaded. (Only for type="checkbox" or type="radio") |
dirnameHTML5 | inputname.dir | Specifies the text direction for the submitted text. |
disabled | disabled | The disabled attribute specifies the <input> element that should be disabled. |
formHTML5 | form_id | The form attribute specifies one or more forms to which the <input> element belongs. |
formactionHTML5 | URL | The attribute specifies the URL to process the file of the input control when the form is submitted. (Only applicable to type="submit" and type="image") |
formenctypeHTML5 | application/x-www-form-urlencoded multipart/form-data text/plain | The attribute specifies how the form data is encoded when submitted to the server (only suitable for type="submit" and type="image") |
formmethodHTML5 | get post | It defines the HTTP method to send form data to the action URL. (Only suitable for type="submit" and type="image") |
formnovalidateHTML5 | formnovalidate | The 'formnovalidate' attribute overrides the 'novalidate' attribute of the <form> element. |
formtargetHTML5 | _blank _self _parent _topframename | It specifies the name or keyword where the received response will be displayed after submitting the form. (Only suitable for type="submit" and type="image") |
heightHTML5 | pixels | It specifies the height of the <input> element. (Only applicable to type="image") |
listHTML5 | datalist_id | The attribute references the <datalist> element, which contains predefined options for the <input> element. |
maxHTML5 | number date | The attribute specifies the maximum value of the <input> element. |
maxlength | number | The attribute specifies the maximum number of characters allowed in the <input> element. |
minHTML5 | number date | The attribute specifies the minimum value of the <input> element. |
multipleHTML5 | multiple | The attribute specifies that multiple values are allowed to be entered into the <input> element. |
name | text | The 'name' attribute specifies the name of the <input> element. |
patternHTML5 | regexp | The 'pattern' attribute specifies the regular expression used to validate the value of the <input> element. |
placeholderHTML5 | text | The 'placeholder' attribute specifies a brief hint that describes the expected value of the input <input> field. . |
readonly | readonly | The 'readonly' attribute specifies that the input field is read-only. |
requiredHTML5 | required | The attribute specifies that the input field must be filled out before submitting the form. |
size | number | The 'size' attribute specifies the visible width of the <input> element in terms of character count. |
src | URL | The 'src' attribute specifies the URL of the image to be displayed as a submit button. (Only applicable to type="image") |
stepHTML5 | number | The step attribute specifies the legal numeric interval for the <input> element. |
type | button checkbox color date datetime datetime-local file hidden image month number password radio range reset search submit tel text time url week | The type attribute specifies the type of the <input> element to be displayed. |
value | text | Specifies the value of the <input> element's value. |
widthHTML5 | pixels | The width attribute specifies the width of the <input> element. (Only for type="image") |
<input> tag supports global attributes, see the complete attribute table HTML Global Attributes.
<input> tag supports all HTML Event Attributes.