HTML input tag

## HTML Reference

HTML by Alphabet HTML by Function HTML Global Attributes HTML Events HTML Canvas HTML Audio/Video HTML Doctypes HTML Colornames HTML Colorpicker HTML Colormixer HTML Character Sets HTML ASCII HTML ISO-8859-1 HTML Symbols HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods Keyboard Shortcuts

## HTML Tags

<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <command> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <head> <header> <h1> - <h6> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <keygen> <label> <legend> <li> <link> <map> <mark> <menu> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <table> <tbody> <td> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

# HTML <input> Tag

« HTML Reference
<ins> Tag »

## Example

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">
</form>
Try it yourself »

## Browser Support

The <input> tag is supported in all major browsers.

## 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.

## Tips and Notes

Note: The <input> element is empty, it contains attributes only.

Tip: Use the <label> element to define labels for <input> elements.

## Differences Between HTML 4.01 and HTML5

In HTML 4.01, the "align" attribute is deprecated, and it is not supported in HTML5. Use CSS to align <input> elements.

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 />.

## Attributes

New : New in HTML5.

Attribute | Value | Description
--- | --- | ---
accept | audio/* video/* image/* MIME_type | Specifies the types of files that the server accepts (only for type="file")
align | left right top middle bottom | Not supported in HTML5. Deprecated in HTML 4.01. Specifies the alignment of an image input (only for type="image")
alt | text | Specifies an alternate text for images (only for type="image")
autocomplete New | on off | Specifies whether an <input> element should have autocomplete enabled
autofocus New | autofocus | Specifies that an <input> element should automatically get focus when the page loads
checked | checked | Specifies that an <input> element should be pre-selected when the page loads (for type="checkbox" or type="radio")
disabled | disabled | Specifies that an <input> element should be disabled
form New | form_id | Specifies one or more forms the <input> element belongs to
formaction New | URL | Specifies the URL of the file that will process the input control when the form is submitted (for type="submit" and type="image")
formenctype New | application/x-www-form-urlencoded multipart/form-data text/plain | Specifies how the form-data should be encoded when submitting it to the server (for type="submit" and type="image")
formmethod New | get post | Defines the HTTP method for sending data to the action URL (for type="submit" and type="image")
formnovalidate New | formnovalidate | Defines that form elements should not be validated when submitted
formtarget New | _blank _self _parent _top framename | Specifies where to display the response that is received after submitting the form (for type="submit" and type="image")
height New | pixels | Specifies the height of an <input> element (only for type="image")
list New | datalist_id | Refers to a <datalist> element that contains pre-defined options for an <input> element
max New | number date | Specifies the maximum value for an <input> element
maxlength | number | Specifies the maximum number of characters allowed in an <input> element
min New | number date | Specifies a minimum value for an <input> element
multiple New | multiple | Specifies that a user can enter more than one value in an <input> element
name | text | Specifies the name of an <input> element
pattern New | regexp | Specifies a regular expression that an <input> element's value is checked against
placeholder New | text | Specifies a short hint that describes the expected value of an <input> element
readonly | readonly | Specifies that an input field is read-only
required New | required | Specifies that an input field must be filled out before submitting the form
size | number | Specifies the width, in characters, of an <input> element
src | URL | Specifies the URL of the image to use as a submit button (only for type="image")
step New | number | Specifies the legal number intervals for an input field

type

button
checkbox
color
date
datetime
datetime-local
email
file
hidden
image
month
number
password
radio
range
reset
search
submit
tel
text
time
url
week

Specifies the type <input> element to display

value | text | Specifies the value of an <input> element
width New | pixels | Specifies the width of an <input> element (only for type="image")

## Global Attributes

The <input> tag also supports the Global Attributes in HTML.

## Event Attributes

The <input> tag also supports the Event Attributes in HTML.

## Related Pages

HTML tutorial: HTML Forms

HTML DOM reference:

- Input Button object
- Input Checkbox object
- Input FileUpload object
- Input Hidden object
- Input Password object
- Input Radio object
- Input Reset object
- Input Submit object
- Input Text object

« HTML Reference
<ins> Tag »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE