HTML <input> tag
Examples
A simple HTML form that contains two text input boxes and a submit button:
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="提交">
</form>
try it"
(Bottom of the page you can view more examples)
Browser Support
Most browsers support <input> tag.
Tag definitions and instructions
<Input> tag specifies the user can enter a field in which the input data.
<Input> elements in the <form> element is used for declaring allows users to enter data input controls.
Input fields can be changed in many ways, depending on the type attribute.
Tips and Notes
Note: <input> element is empty, it contains only tag attributes.
Tip: You can use the <label> to define the label <input> element element.
Differences between HTML 4.01 and HTML5
In HTML 4.01, "align" the data is no longer used. This attribute is not supported in HTML5. You can define the alignment of the <input> elements using CSS.
In HTML5, <input> add several properties, and adds the corresponding value.
Differences between HTML and XHTML
In HTML, <input> tag has no end tag.
In XHTML, <input> tag must be closed properly.
Attributes
New: HTML5 new tags.
Attributes | value | description |
---|---|---|
accept | audio / * video / * image / * MIME_type | Type specifies by file upload to submit documents. (Only for type = "file") |
align | left right top middle bottom | HTML5 obsolete, deprecated. Predetermined alignment of the input image. (Only for type = "image") |
alt | text | Define the image alternate text input. (Only for type = "image") |
AutoComplete New | on off | autocomplete attribute specifies the <input> element input field whether you should enable auto-completion. |
The autofocus New | autofocus | Attribute specifies when the page loads <input> element should automatically get focus. |
checked | checked | Attribute specifies checked when the page loads should be pre-selected <input> elements. (Only for type = "checkbox" or type = "radio") |
disabled | disabled | disabled property provisions should be disabled <input> elements. |
form New | form_id | form attribute specifies <input> elements in the form of one or more belongs. |
formaction New | URL | URL attribute specifies the input control process when the form submissions. (Only for type = "submit" and type = "image") |
formenctype New | application / x-www-form-urlencoded multipart / form-data text / plain | Attribute specifies when the form is submitted to the server how to encode the data (only for type = "submit" and type = "image"). |
formmethod New | get post | Define Send form data to the action URL of the HTTP method. (Only for type = "submit" and type = "image") |
formnovalidate New | formnovalidate | formnovalidate property overrides <form> novalidate attribute of the element. |
formtarget New | _blank _self _parent _top framename | After submitting the form prescribed showing where displays the received response name or keyword. (Only for type = "submit" and type = "image") |
height New | pixels | Provisions <input> element's height. (Only for type = "image") |
List New | datalist_id | Property reference <datalist> element, which contains predefined options <input> elements. |
MAX New | number date | Attribute specifies the <input> maximum element. |
maxlength | number | Attribute specifies the <input> elements maximum number of characters allowed. |
min New | number date | Attribute specifies the <input> element of the minimum. |
Multiple New | multiple | Attribute specifies allows users to enter multiple values <input> elements. |
name | text | name attribute specifies the <input> element's name. |
pattern New | regexp | attribute specifies the pattern used to validate <input> element of the value of regular expressions. |
placeholder New | text | The placeholder attribute provides for a brief description of the message input <input> field is the expected value. |
readonly | readonly | readonly attribute specifies the input field is read-only. |
required New | required | Attribute specifies the input fields must be filled in before submitting the form. |
size | number | Visible width attribute specifies the size in terms of number of characters <input> elements. |
src | URL | Src attribute specifies the URL submit button displayed as an image. (Only for type = "image") |
STEP New | number | step attribute specifies the legal digital <input> element interval. |
type | button checkbox color date datetime datetime-local file hidden image month number password radio range reset search submit tel text time url week | <Input> type attribute specifies the type of element you want to display. |
value | text | Specifies the <input> element value of value. |
width New | pixels | Attribute specifies the width <input> element width. (Only for type = "image") |
Global Properties
<input> tag supports the global attributes, view complete the property sheet HTML Global Attributes .
Event Properties
<input> tag supports all HTML event attributes .