input

The input HTML element represents a typed data field, usually with a form control to allow the user to edit the data.

Syntax

HTML

<input attribute-name="attribute-value"></input>

Attributes

Global

Name Value Description
accept mime-type list Provides the UA with a hint of what file types the server is able to accept
alt normal character data fallback content for the image map
autocomplete on | off Specifies whether the element represents an input control for which a UA is meant to store the value entered by the user (so that the UA can prefill the form later)
autofocus autofocus | empty Specifies that the element represents a control to which a UA is meant to give focus as soon as the document is loaded
checked checked | empty Specifies that the element represents a selected control
disabled disabled | empty Specifies that the element represents a disabled control
form IDREF Identifies a form with which to associate the element
formaction URI Form-submission action for the element
formenctype application/x-www-form-urlencoded | multipart/form-data | text/plain MIME type with which a UA is meant to associate this element for form submission
formmethod get | post | put | delete HTTP method with which a UA is meant to associate this element for form submission
formnovalidate formnovalidate | empty Specifies that the element represents a control whose value is not meant to be validated during form submission
formtarget browsing-context name or keyword Browsing context or keyword that represents the target of the control
height non-negative integer Vertical dimension
list IDREF Identifies a datalist with which to associate the element
max date-time | local date-time | date | month | time | week | float Expected upper bound for the element's value
maxlength positive integer Maximum length of value
min date-time | local date-time | date | month | time | week | float Expected lower bound for the element's value
multiple multiple | empty Specifies that the element allows multiple values
name string Name part of the name/value pair associated with this element for the purposes of form submission
pattern pattern Specifies a regular expression against which a UA is meant to check the value of the control represented by its element
placeholder string Short hint (one word or a short phrase) intended to aid the user when entering data into the control represented by its element
readonly readonly | empty Specifies that element represents a control whose value is not meant to be edited
required required | empty Specifies that the element is a required part of form submission
size positive integer Number of options meant to be shown by the control represented by its element
src URI URL for the audio stream
step any | positive float | positive integer Specifies the value granularity of the element's value
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 that its input element is a one-line plain-text edit control for the input element's value
value string Specifies a value for this input element
width non-negative integer Horizontal dimension

Types

Name Description
button a button with no additional semantics
checkbox a state or option that can be toggled
color a color-well control, for setting the element's value to a string representing a simple color
date a control for setting the element's value to a string representing a date
datetime a control for setting the element's value to a string representing a global date and time (with timezone information)
datetime-local a control for setting the element's value to a string representing a local date and time (with no timezone information)
email a control for editing a list of e-mail addresses given in the element's value
file a list of file items, each consisting of a file name, a file type, and a file body (the contents of the file)
hidden a value that is not intended to be examined or manipulated by the user
image an image from which the UA enables a user to interactively select a pair of coordinates and submit the form, or a button from which the user can submit the form
month a control for setting the element's value to a string representing a month
number a precise control for setting the element's value to a string representing a number
password a one-line plain-text edit control for entering a password
radio a selection of one item from a list of items (a radio button)
range an imprecise control for setting the element's value to a string representing a number
reset a button for resetting a form
search a one-line plain-text edit control for entering one or more search terms
submit a button for submitting a form
tel a one-line plain-text edit control for entering a telephone number
text a one-line plain text edit control for the input element's value
time a control for setting the element's value to a string representing a time (with no timezone information)
url a control for editing an absolute URL given in the element's value
week a control for setting the element's value to a string representing a week

Examples

accept

alt

autocomplete | off

autocomplete | on

autofocus

checked

disabled

form

formaction

formenctype

formmethod | delete

formmethod | get

formmethod | post

formmethod | put

formnovalidate

formtarget

height

list

max

maxlength

min

multiple

name

pattern

placeholder

readonly

required

size

src

step

type

value

width

CSS

Web Hypertext Application Technology Working Group (WHATWG)

Home Menu