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

1 · accept

2 · alt

3 · autocomplete | off

4 · autocomplete | on

5 · autofocus

6 · checked

7 · disabled

8 · form

9 · formaction

10 · formenctype

11 · formmethod | delete

12 · formmethod | get

13 · formmethod | post

14 · formmethod | put

15 · formnovalidate

16 · formtarget

17 · height

18 · list

19 · max

20 · maxlength

21 · min

22 · multiple

23 · name

24 · pattern

25 · placeholder

26 · readonly

27 · required

28 · size

29 · src

30 · step

31 · type

32 · value

33 · width

34 · CSS

!doctype

a

abbr

address

area

article

aside

audio

b

base

bdi

bdo

blockquote

body

br

button

canvas

caption

cite

code

col

colgroup

data

datalist

dd

del

details

dfn

dialog

div

dl

dt

em

embed

fieldset

figcaption

figure

footer

form

h1

h2

h3

h4

h5

h6

head

header

hgroup

hr

html

i

iframe

img

ins

kbd

label

legend

li

link

main

map

mark

menu

meta

meter

nav

noscript

object

ol

optgroup

option

output

p

param

picture

pre

progress

q

rb

rp

rt

rtc

ruby

s

samp

script

section

select

slot

small

source

span

strong

style

sub

summary

sup

table

tbody

td

template

textarea

tfoot

th

thead

time

title

tr

track

u

ul

var

video

wbr

Web Hypertext Application Technology Working Group (WHATWG)

Home Menu