Name

input — HTML 4.01 | HTML5

Synopsis

HTML: <input>; XHTML: <input/> or <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 listed below.

Notes

HTML5 adds a number of new values for the type attribute: datetime, datetime-local, date, month, week, time, number, range, email, url, search, and color. New HTML5 attributes for the input element are listed below.

Start/End Tags

This is an empty element. In HTML, the end tag is forbidden. In XHTML, the element must be closed with a trailing slash as just shown. Developers may include a space character before the slash for backward compatibility with older browsers.

Attributes

Core, Internationalization, Events, Focus; plus onselect, onchange, HTML5 Global Attributes

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.

align="bottom|left|middle|right|top"

Deprecated. Not in HTML5. Specifies the alignment of an image.

alt="text"

Specifies alternative text for an image used as a button.

autocomplete="on|off" ...

Get HTML & XHTML Pocket Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.