<input />

The input element is used to create a variety of form input controls. The type of control is defined by the type attribute. Following is a complete list of attributes (with descriptions) that can be used with the input element. Not all attributes can be used with all control types. The attributes associated with each control type are also provided.


Core(id, class, style, title), Internationalization, Events (onfocus, onblur, onselect, onchange

alt=" text "

Specifies alternative text for an image used as a button.

accept=" MIME type "

Specifies a comma-separated list of content types that a server processing the form will handle correctly. It can be used to filter out nonconforming files when prompting a user to select files to send to the server.

accesskey=" character "

Assigns an access key (keyboard shortcut) to an element for quicker access.


When this attribute is added, a checkbox will be checked by default.


Disables the control for user input. It can only be altered via a script. Browsers may display disabled controls differently (grayed out, for example), which could be useful for dimming certain controls until required info is supplied.

maxlength=" number "

Specifies the maximum number of characters the user can input for this element.

name=" text "

Required by all input types exceptsubmitandreset. Assigns a name to the control. A script program uses this name to reference the control.

readonly="readonly" ...

Get Web Design in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.