HTML <input> Tag


An HTML form with three input fields; two text fields and one submit button:

<form action="demo_form.asp">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
Try it yourself »

Definition and Usage

The <input> tag specifies an input field where the user can enter data.

<input> elements are used within a <form> element to declare input controls that allow users to input data.

An input field can vary in many ways, depending on the type attribute.

Browser Support

<input> Yes Yes Yes Yes Yes Yes

Differences Between HTML 4.01 and HTML5

The "align" attribute is not supported in HTML5.

In HTML5, the <input> tag has several new attributes, and the type attribute has several new values.

Differences Between HTML and XHTML

In HTML, the <input> tag has no end tag.

In XHTML, the <input> tag must be properly closed, like this <input />.


= New in HTML5.

The The The The The The The The The The The The The
Attribute value Description
accept audio /* video /* image /* MIME_type Specifies the type of file submitted through file upload. (Only for type = "file")
align left right top middle bottom HTML5 is deprecated and deprecated. Specifies the alignment of the image input. (Only for type = "image")
alt text Defines alternative text for image input. (Only for type = "image")
autocomplete New on off autocomplete attribute specification<input> Whether the element input field should have autocomplete enabled.
autofocus New autofocus attribute specifies when the page loads<input> element. (Only for type = "checkbox" or type = "radio")
disabled disabled disabled attribute specifies which should be disabled <input> element. (Only for type = "checkbox" or type = "radio")
disabled disabled disabled attribute specifies which should be disabled <input> element.
form New form_id form attribute specifies <input> The form or forms to which the element belongs.
formactionNew URL attribute specifies the URL of a file that processes input controls when the form is submitted. (Only for type = "submit" and type = "image")
formenctype New application /x-www-form-urlencoded multipart /form-data text /plain attribute specifies how the form data is encoded when it is submitted to the server (only type = "submit" and type = "image").
formmethod New get post Defines an HTTP method for sending form data to an action URL. (Only for type = "submit" and type = "image")
formnovalidate New formnovalidate formnovalidate attribute override <form> The novalidate attribute of the element.
formtarget New _blank _self _parent _top framename Specifies the name or keyword where the response is received after the form is submitted. (Only for type = "submit" and type = "image")
height New pixels Requirements <input>The height of the element. (Only for type = "image")
list New datalist_id Attribute reference <datalist> Element containing <input> Element's predefined options.
max New number date Attribute specification <input> The maximum value of the element.
maxlength number Attribute specification <input> The maximum number of characters allowed in an element.
min New number date Attribute specification <input>The minimum value of the element.
multiple New multiple attribute specifies that the user is allowed to enter<input> Multiple values for the element.
name text name attribute specification <input> The name of the element.
pattern New regexp pattern attribute is specified for validation <input> Regular expression for the value of the element.
placeholder New text placeholder attribute specifies a descriptive input <input> A short tip for the expected value of the field .
readonly readonly readonly attribute specifies that the input field is read-only.
required New required attribute specifies that input fields must be filled out before the form is submitted.
size number size attribute specifies the number of characters <input> The visible width of the element.
src URL src attribute specifies the URL of the image displayed as the submit button. (Only for type = "image")
step New number step attribute requirements <input> The legal number interval of the element.
type button
type attribute specifies what to display <input> The type of the element.
value text Specify <input> The value of element value.
widthNew pixels width attribute specification <input> The width of the element. (Only for type = "image")