The HTML <input> element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent.

Content categories Flow content, listed, submittable, resettable, form-associated element, phrasing content. If the type is not hidden, then labelable element, palpable content.
Permitted content None, it is an empty element.
Tag omission Must have a start tag and must not have an end tag.
Permitted parents Any element that accepts phrasing content.
Permitted ARIA roles
DOM interface HTMLInputElement

Form <input> types

How an <input> works varies considerably depending on the value of its type attribute, hence the different types are covered in their own separate reference pages. If this attributes is not specified, the default type adopted is text.

The available types are as follows:

  • button: A push button with no default behavior.
  • checkbox: A check box allowing single values to be selected/deselected.
  • color: HTML5 A control for specifying a color. A color picker's UI has no required features other than accepting simple colors as text (more info).
  • date: HTML5 A control for entering a date (year, month, and day, with no time).
  • datetime-local: HTML5 A control for entering a date and time, with no time zone.
  • email: HTML5 A field for editing an e-mail address.
  • file: A control that lets the user select a file. Use the accept attribute to define the types of files that the control can select.
  • hidden: A control that is not displayed but whose value is submitted to the server.
  • image: A graphical submit button. You must use the src attribute to define the source of the image and the alt attribute to define alternative text. You can use the height and width attributes to define the size of the image in pixels.
  • month: HTML5 A control for entering a month and year, with no time zone.
  • number: HTML5 A control for entering a number.
  • password: A single-line text field whose value is obscured. Use the maxlength and minlength attributes to specify the maximum length of the value that can be entered.
    Note: Any forms involving sensitive information like passwords (e.g. login forms) should be served over HTTPS; Firefox now implements multiple mechanisms to warn against insecure login forms — see Insecure passwords. Other browsers are also implementing similar mechanisms.
  • radio: A radio button, allowing a single value to be selected out of multiple choices.
  • range: HTML5 A control for entering a number whose exact value is not important.
  • reset: A button that resets the contents of the form to default values.
  • search: HTML5 A single-line text field for entering search strings. Line-breaks are automatically removed from the input value.
  • submit: A button that submits the form.
  • tel: HTML5 A control for entering a telephone number.
  • text: A single-line text field. Line-breaks are automatically removed from the input value.
  • time: HTML5 A control for entering a time value with no time zone.
  • url: HTML5 A field for entering a URL.
  • week: HTML5 A control for entering a date consisting of a week-year number and a week number with no time zone.

Some input types are now obsolete:

Attributes

Global <input> attributes

This section lists the attributes available to all form <input> types. Non-global attributes — and global attributes that behave differently when specified on different <input> types — are listed on those types' individual pages.

Note: This includes the global HTML attributes.

type
The type of control to render. See Form <input> types for the individual types, with links to more information about each.
accept
If the value of the type attribute is file, this attribute indicates the types of files that the server accepts — otherwise it's ignored. The value must be comma-separated unique “content type specifiers”:
  • A case-insensitive file extension starting with the STOP character (U+002E). (e.g. .jpg, .png, .doc).
  • A valid MIME type with no extensions.
  • audio/* representing sound files. HTML5
  • video/* representing video files. HTML5
  • image/* representing image files. HTML5
accesskey HTML 4 only, Obsolete since HTML5
Sets a keyboard key that the user can press to focus the control. This attribute is global in HTML5 — see the accesskey page for more info.
autocomplete HTML5
This attribute indicates if the input can be automatically completed by the browser, usually by remembering previous values the user has entered.
"off"
The browser is not permitted to automatically enter or select a value for this field. It is possible that the document or application provides its own autocomplete feature, or that security concerns require that the field's value not be automatically entered.
Note: In most modern browsers, setting autocomplete to "off" will not prevent a password manager from asking the user if they would like to save username and password information, or from automatically filling in those values in a site's login form. See the autocomplete attribute and login fields.
"on"
The browser is allowed to automatically complete the input. No guidance is provided as to the type of data expected in the field, so the browser may use its own judgement.
"name"
The field expects the value to be a person's full name. Using "name" rather than breaking the name down into its components is generally preferred because it avoids dealing with the wide diversity of human names and how they are structured; however, you can use the following autocomplete values if you do need to break the name down into its components:
"honorific-prefix"
The prefix or title, such as "Mrs.", "Mr.", "Miss", "Ms.", "Dr.", or "Mlle.".
"given-name"
The given (or "first") name.
"additional-name"
The middle name.
"family-name"
The family (or "last") name.
"honorific-suffix"
The suffix, such as "Jr.", "B.Sc.", "PhD.", "MBASW", or "IV".
"nickname"
A nickname or handle.
"email"
An email address.
"username"
A username or account name.
"new-password"
A new password. When creating a new account or changing passwords, this is the "Enter your new password" field, as opposed to any "Enter your current password" field that might be present. This may be used by the browser both to avoid accidentally filling in an existing password and to offer assistance in creating a secure password.
"current-password"
The user's current password.
"organization-title"
A job title, or the title a person has within an organization, such as "Senior Technical Writer", "President", or "Assistant Troop Leader".
"organization"
A company or organization name, such as "Acme Widget Company" or "Girl Scouts of America".
"street-address"
A street address. This can be multiple lines of text, and should fully identify the location of the address within its second administrative level (typically a city or town), but should not include the city name, ZIP or postal code, or country name.
"address-line1", "address-line2", "address-line3"
Each individual line of the street address. These should only be present if the "street-address" is also present.
"address-level4"
The finest-grained administrative level, in addresses which have four levels.
"address-level3"
The third administrative level, in addresses with at least three administrative levels.
"address-level2"
The second administrative level, in addresses with at least two of them. In countries with two administrative levels, this would typically be the city, town, village, or other locality in which the address is located.
"address-level1"
The first administrative level in the address. This is typically the province in which the address is located. In the United States, this would be the state. In Switzerland, the canton. In the United Kingdom, the post town.
"country"
A country code.
"country-name"
A country name.
"postal-code"
A postal code (in the United States, this is the ZIP code).
"cc-name"
The full name as printed on or associated with a payment instrument such as a credit card. Using a full name field is preferred, typically, over breaking the name into pieces.
"cc-given-name"
A given (first) name as given on a payment instrument like a credit card.
"cc-additional-name"
A middle name as given on a payment instrument or credit card.
"cc-family-name"
A family name, as given on a credit card.
"cc-number"
A credit card number or other number identifying a payment method, such as an account number.
"cc-exp"
A payment method expiration date, typically in the form "MM/YY" or "MM/YYYY".
"cc-exp-month"
The month in which the payment method expires.
"cc-exp-year"
The year in which the payment method expires.
"cc-csc"
The security code for the payment instrument; on credit cards, this is the 3-digit verification number on the back of the card.
"cc-type"
The type of payment instrument (such as "Visa" or "Master Card").
"transaction-currency"
The currency in which the transaction is to take place.
"transaction-amount"
The amount, given in the currency specified by "transaction-currency", of the transaction, for a payment form.
"language"
A preferred language, given as a valid BCP 47 language tag.
"bday"
A birth date, as a full date.
"bday-day"
The day of the month of a birth date.
"bday-month"
The month of the year of a birth date.
"bday-year"
The year of a birth date.
"sex"
A gender identity (such as "Female", "Fa'afafine", "Male"), as freeform text without newlines.
"tel"
A full telephone number, including the country code. If you need to break the phone number up into its components, you can use these values for those fields:
"tel-country-code"
The country code, such as "1" for the United States, Canada, and other areas in North America and parts of the Caribbean.
"tel-national"
The entire phone number without the country code component, including a country-internal prefix. For the phone number "1-855-555-6502", this field's value would be "855-555-6502".
"tel-area-code"
The area code, with any country-internal prefix applied if appropriate.
"tel-local"
The phone number without the country or area code. This can be split further into two parts, for phone numbers which have an exchange number and then a number within the exchange. For the phone number "555-6502", use "tel-local-prefix" for "555" and "tel-local-suffix" for "6502".
"tel-extension"
A telephone extension code within the phone number, such as a room or suite number in a hotel or an office extension in a company.
"email"
An email address.
"impp"
A URL for an instant messaging protocol endpoint, such as "xmpp:username@example.net".
"url"
A URL, such as a home page or company web site address as appropriate given the context of the other fields in the form.
"photo"
The URL of an image representing the person, company, or contact information given in the other fields in the form.

See the WHATWG Standard for more detailed information.

Note: The autocomplete attribute also controls whether Firefox will — unlike other browsers — persist the dynamic disabled state and (if applicable) dynamic checkedness of an <input> across page loads. The persistence feature is enabled by default. Setting the value of the autocomplete attribute to off disables this feature. This works even when the autocomplete attribute would normally not apply to the <input> by virtue of its type. See bug 654072.

See The HTML autocomplete attribute for additional information.
autofocus HTML5
This Boolean attribute specifies that the input should have focus when the page loads, unless the user overrides it (e.g. by typing in a different control). Only one element in a document can have the autofocus attribute. It cannot be applied if the type attribute is hidden, because hidden inputs cannot be focused. Note that the input may be focused before the DOMContentLoaded event fires.
Warning: Automatically focusing a form control can confuse visually-impaired people who using screen-reading technology. When autofocus is assigned, screen-readers "teleport" their user to the form control without warning them beforehand.
capture

If the value of the type attribute is file, this Boolean attribute indicates that capture of media directly from the device's sensors using a media capture mechanism is preferred, such as a webcam or microphone.

checked

If the value of the type attribute is radio or checkbox, this Boolean attribute pre-checks the control before the user interacts with it.

Unlike other browsers, Firefox by default persists the dynamic checked state of an <input> across page loads. Use the autocomplete attribute to control this feature.

disabled

This Boolean attribute prevents the user from interacting with the input. In particular, the click event is not dispatched on disabled controls, and disabled controls aren't submitted with their form.

Unlike other browsers, Firefox will by default persist the dynamic disabled state of an <input> across page loads. Use the autocomplete attribute to control this feature.

form HTML5
The form element that the input element is associated with (its form owner). The value of the attribute must be an id of a <form> element in the same document. If this attribute isn't used, the <input> element is associated with its nearest ancestor <form> element, if any. This attribute lets you to place <input> elements anywhere within a document, not just as descendants of form elements. An input can be associated with at most one form.
formaction HTML5
The URL that processes the data submitted by the input element, if it is a submit button or image. This attribute overrides the action attribute of the element's form owner.
formenctype HTML5
If the input element is a submit button or image, this attribute specifies the content encoding that is used to submit the form data to the server. Possible values:
  • application/x-www-form-urlencoded: The default value if the attribute is not specified.
  • multipart/form-data: Use this value if you are using an <input> element with the type attribute set to file.
  • text/plain: This encoding is mostly for debugging.

This attribute overrides the enctype attribute of the element's form owner.

formmethod HTML5
If the input element is a submit button or image, this attribute specifies the HTTP method that the browser uses to submit the form. Possible values:
  • post: The data from the form is included in the body of the form and is sent to the server.
  • get: The data from the form are appended to the form attribute URL, with a '?' as a separator, and the resulting URL is sent to the server. Use this method when the form has no side-effects and contains only ASCII characters.

This attribute overrides the method attribute of the element's form owner.

formnovalidate HTML5
If the input element is a submit button or image, this Boolean attribute specifies that the form shouldn't be validated before submission. This attribute overrides the novalidate attribute of the element's form owner.
formtarget HTML5
If the input element is a submit button or image, this attribute is a name or keyword indicating where to display the response that is received by submitting the form. This is a name of, or keyword for, a browsing context (e.g. tab, window, or inline frame). This attribute overrides the target attribute of the elements's form owner. The following keywords have special meanings:
  • _self: Load the response into the same browsing context as the current one. This is the default if the attribute is not specified.
  • _blank: Load the response into a new unnamed browsing context.
  • _parent: Load the response into the parent browsing context of the current one. If there is no parent, this option behaves the same way as _self.
  • _top: Load the response into the top-level browsing context (i.e. the browsing context that is an ancestor of the current one, and has no parent). If there is no parent, this option behaves the same way as _self.
height HTML5
If the value of the type attribute is image, defines the height of the image displayed for the button in pixels.
inputmode HTML5
A hint to browsers for which virtual keyboard to display. This attribute applies when the the type attribute is text, password, email, or url. Possible values:
  • none: No virtual keyboard should be displayed.
  • text: Text input in the user's locale.
  • decimal: Fractional numeric input.
  • numeric: Numeric input.
  • tel: Telephone input, including asterisk and pound key. Prefer <input type="tel">.
  • search: A virtual keyboard optimized for search input.
  • email: Email input. Prefer <input type="email">.
  • url: URL input. Prefer <input type="url">.
Spec conflict: The WHATWG spec lists inputmode, and modern browsers are working towards supporting it. The W3C HTML 5.2 spec however no longer lists it (i.e. marks it as obsolete). You should consider the WHATWG definition as correct, until a consensus is reached.
list HTML5
Points to a <datalist> of predefined options to suggest to the user. The value must be the id of a <datalist> element in the same document. Browsers display only valid options for the input. This attribute is ignored when the type attribute is hidden, checkbox, radio, file, or a button type.
max HTML5
The maximum (numeric or date-time) value for the input. Must not be less than its minimum (min attribute) value.
maxlength
If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the maximum number of characters (in UTF-16 code units) that the user can enter. For other control types, it is ignored.
min HTML5
The minimum (numeric or date-time) value for this input, which must not be greater than its maximum (max attribute) value.
minlength HTML5
If the value of the type attribute is text, email, search, password, tel, or url, this attribute specifies the minimum number of characters (in UTF-16 code points) that the user can enter. For other control types, it is ignored.
multiple HTML5
This Boolean attribute indicates whether the user can enter more than one value. This attribute only applies when the type attribute is set to email or file.
name
The name of the control, which is submitted with the control's value as part of the form data. If no name is specified or it is empty, the control's value is not submitted with the form.
pattern HTML5
A regular expression that the control's value is checked against. The pattern must match the entire value. Use the title attribute to describe the pattern to help the user. This attribute only applies when the value of the type attribute is text, search, tel, url, email, or password. The regular expression language is the same as the JavaScript RegExp algorithm, with the 'u' parameter that makes it treat the pattern as a sequence of unicode code points. The pattern is not surrounded by forward slashes.
placeholder HTML5
A hint to the user of what can be entered in the control, typically in the form of an example of the type of information that should be entered. The placeholder text must not contain carriage returns or line-feeds.
Note: Before using placeholder, please see the section Labels and placeholders to ensure that you use them correctly if at all. Placeholders can be confusing and can disrupt certain operations in unexpected ways.
readonly HTML5
This Boolean attribute prevents the user from modifying the value of the input. It is ignored if the value of the type attribute is hidden, range, color, checkbox, radio, file, or a button type (such as button or submit).
required HTML5
This attribute specifies that the user must fill in a value before submitting a form. It cannot be used when the type attribute is hidden, image, or a button type (submit, reset, or button). The :optional and :required CSS pseudo-classes will be applied to the field as appropriate.
size
The initial size of the control. Starting in HTML5, this attribute applies only when the type attribute is set to text, search, tel, url, email, or password, otherwise it is ignored. The size must be an integer greater than zero. The default value is 20.
HTML5 states "the user agent should ensure that at least that many characters are visible", but different characters have different widths in certain fonts. In some browsers, a certain string with x characters will not be entirely visible even if size is defined as x.
spellcheck HTML5
Setting the value of this attribute to true indicates that the element needs to have its spelling and grammar checked. The value default indicates that the element is to act according to a default behavior, possibly based on the parent element's own spellcheck value. The value false indicates that the element should not be checked.
src
If the value of the type attribute is image, this attribute specifies the URL of the image file to display on the graphical submit button.
step HTML5
Works with the min and max attributes to limit the increments at which a numeric or date-time value can be set. It can be the string any or a positive floating point number. If this attribute is not set to any, the control accepts only values at multiples of the step value greater than the minimum.
tabindex element-specific in HTML 4, global in HTML5
The position of the element in the tabbing navigation order for the current document.
usemap HTML 4 only, Obsolete since HTML5
The name of a <map> element to be used as an image map.
value
The initial value of the control. This attribute is optional except when the value of the type attribute is radio or checkbox.
When reloading the page, Firefox and IE will ignore the value specified in the HTML source, if the value was changed before the reload.
width HTML5
If the value of the type attribute is image, this attribute defines the width of the image displayed for the button in pixels.

Non-standard <input> attributes

autocorrect
This is a non-standard attribute supported by Safari that is used to control whether autocorrection should be enabled when the user is entering/editing the text value of the <input>. Possible attribute values are:
  • on: Enable autocorrection.
  • off: Disable autocorrection.
autocorrect documentation in the Safari HTML Reference.
incremental
This is a nonstandard attribute supported by WebKit (Safari) and Blink (Chrome) that only applies when the type is search. If the attribute is present, regardless of what its value is, the <input> fires search events as the user edits the text value. The event is only fired after an implementation-defined timeout has elapsed since the most recent keystroke, and new keystrokes reset the timeout. In other words, the event firing is debounced. If the attribute is absent, the search event is only fired when the user explicitly initiates a search (e.g. by pressing the Enter key while within field). incremental documentation in the Safari HTML Reference
mozactionhint
Specifies an "action hint" used to determine how to label the enter key on mobile devices with virtual keyboards. Supported values are go, done, next, search, and send. These automatically get mapped to the appropriate string and are case-insensitive.
results
This is a nonstandard attribute supported by Safari that only applies when the type is search. It is used to control the maximum number of entries that should be displayed in the <input>'s native dropdown list of past search queries. Its value should be a nonnegative decimal integer.
webkitdirectory
This Boolean attribute indicates if the selector used when the type attribute is file has to allow for the selection of directories only.
x-moz-errormessage
This Mozilla extension allows you to specify the error message to display when a field doesn't successfully validate.

Styling input elements

You can style <input> elements using various color-related attributes in particular. One unusual one that is specific to text entry-related elements is the CSS caret-color property, which lets you set the color used to draw the text input caret:

HTML

<label for="textInput">Note the red caret:</label>
<input id="textInput" class="custom" size="32">

CSS

input.custom {
  caret-color: red;
  font: 16px "Helvetica", "Arial", "sans-serif"
}

Result

For more information about adding color to elements in HTML, see Applying color to HTML elements using CSS.

Labels and placeholders

TL;DR: To save you time, here's the key point: don't use the placeholder attribute if you can avoid it. If you need to label an <input> element, use the <label> element.

There are three seemingly similar ways to associate assistive text with an <input>. However, they are actually quite different, and only one of them is always a good choice. Here we will look at each of them and learn best practices for providing the user with guidance when entering data into a form.

The <label> element

The <label> element is the only way to provide explanatory information about a form field that is always appropriate (aside from any layout concerns you have). It's never a bad idea to use a <label> to explain what should be entered into an <input> or <textarea>.

The placeholder attribute

The placeholder attribute lets you specify a text that appears within the <input> element's content area itself when empty. It's intended to be used to show an example input, rather than an explanation or prompt, but tends to be badly misused.

Here are two inputs that take a password, each with a placeholder:

Example of correct and incorrect placeholder usage

The first one uses a placeholder string "MyGr8P@sswrd", demonstrating what a password might look like. And no, that's not really a great password.

The second one uses a prompt string, "Enter your password" as a placeholder. The first, and most obvious, problem with doing this is that as soon as the user types their first character, they no longer have a prompt explaining what that field is for.

That's why, instead, you should use the <label> element. The placeholder should never be required in order to understand your forms. While some people are able to remember what a given empty box is meant for after its only identifying text vanishes, others cannot.

If the user can't understand your form if the placeholders are missing (say, in a browser that doesn't support placeholder, or in the case above where the user starts typing then gets confused), you're not using placeholders properly.

In addition, browsers with automatic page translation features may skip over attributes when translating. That means the placeholder may not get translated, resulting in important information not being translated.

If you feel like you need to use a placeholder, it's possible to use both a placeholder and a label:

Unadorned text adjacent to the <input> element

You can also just have plain text adjacent to the <input> element, like this:

<p>Enter your name: <input id="name" type="text" size="30"></p>

Please don't do this. This doesn't create a relationship between the prompt and the <input> element, which is important for reasons we'll get into in the next section.

Why you should use labels

In addition to the information provided above, there are a number of other reasons why <label> is the best way to explain <input>s:

  • The semantic pairing of <input> and <label> elements is useful for assistive technologies such as screen readers. By pairing them using the <label>'s for attribute, you bond the label to the input in a way that lets screen readers describe inputs to users more precisely.
  • By pairing a <label> with an <input>, clicking on either one will focus the <input>. If you use plaintext to "label" your input, this won't happen. Having the prompt part of the activation area for the input is helpful for people with motor control conditions.
  • As web developers, it's important that we never assume that people will know all the things that we know. The diversity of people using the web—and by extension your web site—practically guarantees that some of your site's visitors will have some variation in thought processes and/or circumstances that leads them to interpret your forms very differently from you without clear and properly-presented labels.

Examples

You can find multiple examples of <input> element usage on the pages covering each individual type — see Form <input> types, and also see the Live example at the top of the article.

Specifications

Specification Status Comment
HTML Living Standard
The definition of '<input>' in that specification.
Living Standard  
HTML Media Capture
The definition of '<input capture>' in that specification.
Recommendation Adds the capture element
HTML5
The definition of '<input>' in that specification.
Recommendation  
HTML 4.01 Specification
The definition of '<form>' in that specification.
Recommendation  

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
type="button"1 Yes1 Yes Yes1
type="checkbox" Yes Yes Yes Yes Yes Yes
type="color"2014291 No1210
type="date"201257 No11 No2
type="datetime-local"2012 No3 No11 No2
type="email"5 ? Yes1011 Yes
type="file"1 ?16 Yes111
type="hidden"1 Yes1 Yes21
type="image" Yes ? Yes Yes Yes Yes
type="month"2012 No7 No11 No8
type="number" Yes ? Yes10 Yes Yes
type="password"1 ?1221
type="radio" Yes Yes Yes Yes Yes Yes
type="range"4122310113.1
type="reset"1 ?110 Yes Yes1
type="search"51241010.65
type="submit"1 Yes111 Yes Yes1
type="tel" Yes Yes Yes1011 Yes
type="text"1 Yes1 Yes Yes1
type="time"201257 No10 No
type="url"1 Yes Yes1011 Yes
type="week"2012 No7 No11 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
type="button" Yes1 Yes4 Yes Yes ?
type="checkbox" Yes Yes Yes4 Yes Yes ?
type="color"4.4 ?1427 Yes No ?
type="date" Yes Yes ?57115 ?
type="datetime-local" Yes Yes ? Yes11 Yes ?
type="email" ? ? ?4 Yes3.14 5 ?
type="file" Yes Yes ?41 Yes ?
type="hidden" Yes Yes Yes4 Yes Yes ?
type="image" Yes ? ? Yes Yes Yes ?
type="month" Yes Yes ? No Yes Yes ?
type="number" Yes Yes ? Yes Yes Yes ?
type="password" ? Yes ?4 Yes Yes ?
type="radio" Yes Yes Yes4 Yes Yes ?
type="range"

4.3

2.1 — 4.39

57 ?52 Yes5.1 ?
type="reset" Yes Yes ?410 Yes Yes ?
type="search" Yes Yes Yes Yes Yes Yes ?
type="submit" Yes Yes Yes411 Yes Yes ?
type="tel" Yes Yes ? Yes Yes Yes ?
type="text" Yes Yes Yes4 Yes Yes ?
type="time" Yes20 Yes57 Yes No ?
type="url" Yes Yes Yes Yes Yes Yes ?
type="week" Yes Yes Yes Yes Yes Yes ?

1. Firefox doesn't yet support inputs of type color on Windows Touch.

2. The input type is recognized, but there is no date-specific control.

3. See bug 888320 and TPE DOM/Date time input types.

4. Doesn't do validation, but instead offers a custom 'email' keyboard, which is designed to make entering email addresses easier.

5. Automatically applies a default style of opacity: 0.4 to disable textual <input> elements, including those of type 'email'. Other major browsers don't currently share this particular default style.

6. You can set as well as get the value of HTMLInputElement.files in all modern browsers; this was most recently added to Firefox, in version 57 (see bug 1384030).

7. See bug 888320.

8. The input type is recognized, but there is no month-specific control.

9. Android WebView recognizes the range type, but doesn't implement a range-specific control.

10. Unlike other browsers, Firefox by default persists the dynamic disabled state of a &ltbutton&gt across page loads. Use the autocomplete attribute to control this feature.

11. Unlike other browsers, Firefox by default persists the dynamic disabled state of a <button> across page loads. Use the autocomplete attribute to control this feature.

</button>

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 (Yes) 1.0 (1.7 or earlier) (Yes) 1.0 1.0
type="time" 20 (Yes) 57 (57) No support 10.62 No support[1]
accept (Yes) No support (Yes) 10 ? No support
mozactionhint No support No support 4.0 (2.0) No support No support No support
autocapitalize 43 No support ? ? ? (Yes) [3]
autofocus, max, min, pattern, placeholder, required, step, list, multiple 5.0 (Yes) (Yes) 10 9.6 5.0
capture Chrome for Android (0.16) No support ? ? ? ?
fakepath added to file input values (Yes) No support 53 (53) (Yes) (Yes) (Yes)
form 10 (Yes) 4 No support[7] 9.5 5.0
formaction, formenctype, formmethod, formnovalidate, formtarget 9.0 (Yes) 4.0 (2.0) 10 10.62 5.1
incremental (Yes) No support (Yes) No support No support (Yes)
inputmode (Yes) No support 17 (17) No support No support No support
minlength 40.0 No support ? ? ? ?
readonly 1.0 (Yes) 1.0 (1.7 or earlier) 6[2] 1.0 1.0
spellcheck 10.0 No support 3.6 (1.9.2) 10 11.0 4.0
webkitdirectory (Yes) (Yes) 49.0 (49.0) ? (Yes) (Yes)
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) 4.0 (2.0) (Yes) (Yes) (Yes)
type="time" No support (Yes) 57 (57) No support 10.62 (Yes)[1]
accept (Yes) No support (Yes) ? (Yes) (Yes)
autocapitalize ? No support ? ? ? (Yes)[3]
autofocus, max, min, pattern, placeholder, required, step, list, multiple (Yes) (Yes) (Yes)[5] ? (Yes) (Yes)
capture 3.0 No support 10.0 (10.0) ? ? 6.0
fakepath added to file input values (Yes) No support 53.0 (53) (Yes) (Yes) (Yes)
form, formaction, formenctype, formmethod, formnovalidate, formtarget ? (Yes) ? ? ? ?
minlength ? No support No support ? 27.0 ?
spellcheck ? No support 4.0 (2.0) ? 11.0 ?
webkitdirectory (Yes) (Yes) 49.0 (49.0) ? (Yes) (Yes)

[1] It is recognized but there is no UI.

[2] Missing for type="checkbox" and type="radio".

[3] In Safari autocapitalize="words" capitalizes every word's second character.

[4] datetime has been removed from the spec and browsers in favour of datetime-local.

[5] see bug 1355389

[6] Not yet implemented. For progress, see bug 888320 and TPE DOM/Date time input types.

Notes

File inputs

  1. Starting in Gecko 2.0, calling the click() method on an <input> element of type file opens the file picker and lets the user select files. See Using files from web applications for an example and more details.

  2. You cannot set the value of a file picker from a script — doing something like the following has no effect:

    var e = getElementById("someFileInputElement");
    e.value = "foo";
    
  3. When a file is chosen using an <input type="file">, the real path to the source file is not shown in the input's value attribute for obvious security reasons. Instead, the filename is shown, with C:\fakepath\ appended to the beginning of it. There are some historical reasons for this quirk, but it is supported across all modern browsers, and in fact is defined in the spec.

Error messages

If you want Firefox to present a custom error message when a field fails to validate, you can use the x-moz-errormessage attribute to do so:

<input type="email"
 x-moz-errormessage="Please specify a valid email address.">

Note, however, that this is not standard and will not have an effect on other browsers.

Localization

The allowed inputs for certain <input> types depend on the locale. In some locales, 1,000.00 is a valid number, while in other locales the valid way to enter this number is 1.000,00.

Firefox uses the following heuristics to determine the locale to validate the user's input (at least for type="number"):

  • Try the language specified by a lang/xml:lang attribute on the element or any of its parents.
  • Try the language specified by any Content-Language HTTP header or
  • If none specified, use the browser's locale.

Using mozactionhint on Firefox mobile

You can use the mozactionhint attribute to specify the text for the label of the enter key on the virtual keyboard when your form is rendered on Firefox mobile. For example, to have a "Next" label, you can do this:

<input type="text" mozactionhint="next">

The result is:

Note the "Next" key in the lower-right corner of the keyboard.

See also

Document Tags and Contributors

Last updated by: Rob_Belics,