Name
input
Synopsis
<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.
Usage
- Categories:
Flow content, phrasing content. If the
type
attribute is not in the Hidden state, then interactive content, palpable content, as well as “listed, labelable, submittable, and resettable form-associated content.” If thetype
attribute is in the Hidden state, then “listed, submittable, and resettable form-associated content.”- Permitted contexts:
Where phrasing content is expected
- Permitted content:
Empty
- Start/end tags:
This is an empty (void) element, meaning it has only a start tag and may not have any contents. In HTML, the end tag is forbidden. In XHTML, the element must be closed with a trailing slash (
<input/>
or<input />
).
Attributes
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. Applies to the
file
input type only.alt="
text
"
Specifies alternative text for an image used as a button. Applies to the
image
input type.autocomplete="on|off"
Not in HTML 4.01. Allows the ...
Get HTML5 Pocket Reference, 5th 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.