HTML <input> element
Creates a form control whose behavior depends on type. Attributes are applicable by input state, and a visible label is usually necessary. This is a void element. Each type has a different value model, validity constraints and applicable attributes. Associate a visible label, choose the type based on the data rather than its visual appearance, and use name for submitted form data. Native validation improves usability but must not replace server-side validation. A disabled control is normally omitted from submission. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
<input type="text" name="name">Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| accept | comma-separated file types | Hints which files a file picker should offer, using extensions, MIME types or supported wildcards. It does not validate uploaded content; check files on the server. |
| alpha | boolean | Requests alpha-channel support in a color input. This is a newer feature; do not assume every picker or browser handles transparency. |
| alt | text | Text alternative for image submit controls; not used on ordinary text inputs. |
| autocomplete | ordered autofill tokens or on/off | Gives the browser the purpose of a form field or controls autofill. Use meaningful tokens such as email or current-password. A browser may still offer password-manager autofill even with off. |
| checked | boolean | Sets the default checked state for a checkbox or radio input. The current checked state is a DOM property and may change independently after user interaction. |
| colorspace | enumerated: limited-srgb, display-p3 | Selects the color-space mode for a color input where supported. Use a conventional sRGB hex color when broad interoperability matters. |
| dirname | form field name | Adds a separate form data entry recording the directionality of a supported text input or textarea. The submitted direction is ltr or rtl. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| formaction | URL | Overrides the associated form's submission destination for this submit button or image submit input. |
| formenctype | form encoding keyword | Overrides the associated form's encoding when this submit control initiates submission. Use multipart/form-data for file upload requests. |
| formmethod | enumerated: get, post, dialog | Overrides the form submission method for a particular submit control. dialog closes an associated dialog instead of making an ordinary network submission. |
| formnovalidate | boolean | Bypasses native constraint validation when the corresponding submit control is used. Server-side validation is still required. |
| formtarget | browsing context name or keyword | Overrides the target browsing context for the submission initiated by this control. |
| height | non-negative integer | Sets an element-specific height, commonly in CSS pixels. On images, pair it with width matching the intrinsic aspect ratio to reserve layout space. It is not a CSS length with units. |
| list | datalist ID | Associates a supported input with a datalist of suggestions. It does not restrict the input to the listed values; use select when a closed set is required. |
| max | number or type-specific date/time | Sets the upper constraint for applicable input types or the upper bound for meter and progress. Format and defaults depend on the element and input type. |
| maxlength | non-negative integer | Limits text length in applicable inputs and textareas, measured in UTF-16 code units. It is not a byte limit or a reliable count of user-perceived characters. |
| min | number or type-specific date/time | Sets the lower constraint for eligible inputs or the lower bound of meter. It must use the type's value syntax; the effect depends on the element. |
| minlength | non-negative integer | Sets the minimum length of user-entered nonempty text in applicable fields, measured in UTF-16 code units. Add required if an empty value must also be invalid. |
| multiple | boolean | Allows multiple files, comma-separated email addresses or multiple select options depending on the element. It does not apply to ordinary text inputs. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| pattern | JavaScript regular expression source | Adds a whole-value pattern constraint to supported text-like inputs. Modern HTML uses Unicode Sets (v flag) semantics. Do not wrap the pattern in slash delimiters; combine with required to reject empty input. |
| placeholder | short text hint | Shows a temporary hint when a supported form field is empty. It disappears during entry and is not a substitute for a persistent accessible label. |
| popovertarget | element ID | Identifies a popover controlled by a button or eligible input button. The target must have the popover attribute; use the ID without #. |
| popovertargetaction | enumerated: toggle, show, hide | Specifies the action a popover invoker performs. The default is toggle. The target must be identified by popovertarget. |
| readonly | boolean | Prevents user editing of eligible inputs and textareas without disabling their normal submission. It does not apply to every control type, and scripts can still alter the value. |
| required | boolean | Makes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation. |
| size | positive integer | On applicable text inputs, suggests width in characters; on select, specifies a visible option count. It does not constrain the text length or number of choices. |
| src | URL | Specifies the resource to load for the given element, such as an image, script or media file. The resource type, loading behavior and security rules depend on the element. |
| step | positive number or any | Defines allowed value increments for applicable number and date/time inputs. The step base and default depend on the type and min or value. any disables step mismatch validation. |
| switch | boolean | Requests a switch-style presentation for a checkbox in supporting browsers. Its checkbox state and form submission remain the underlying behavior. Use a visible label and test browser support. |
| type | input type keyword | Selects one of the 22 input states. Missing or invalid type falls back to text. Other attributes apply only to particular states. |
| value | type-dependent value | Default value or submitted value depending on type. A file input cannot be prefilled with a path. |
| width | non-negative integer | Defines element-specific width, commonly in CSS pixels. On images it can establish an intrinsic aspect ratio together with height; on canvas it sets the bitmap width. |
| autofocus | boolean | Requests initial focus when the document or relevant dialog or popover is shown. Avoid unexpected focus changes that disorient keyboard or screen reader users. |
| inputmode | enumerated: none, text, decimal, numeric, tel, search, email, url | Hints which virtual keyboard layout to present. It does not constrain permitted values or perform validation. Use it for text identifiers that need a numeric keypad. |
| autocapitalize | enumerated: none, off, sentences, on, words, characters | Hints how a virtual keyboard should capitalize text. It is not validation and has no effect on some input types, such as email and password. |
| autocorrect | enumerated: on, off | Hints whether automatic spelling correction is enabled for editable text. Browser and platform support varies; use off where exact identifiers matter. |
| enterkeyhint | enumerated: enter, done, go, next, previous, search, send | Hints which action label or icon a virtual keyboard should show for Enter. It does not implement form submission or navigation. |
Return Value
Content model: Empty; this void element cannot contain children and must not have an end tag. No closing tag.
Working Example
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>HTML example</title> </head> <body> <label for="name">Name</label> <input id="name" name="name" required> </body></html>Browser Compatibility
Minimum supported versions across modern rendering engines