input (HTML element)
Example
Here’s a simple text
input (see type for other
input examples):
<form> <label for="firstname">First name</label> <input type="text" name="firstname" id="firstname"/> </form>
- Type
- inline element
- Contains
- nothing—empty element
- Contained by
- block-level
elements, inline elements
(except
button)
Description
Describing the
input element simply is not straightforward, as there
is much variation in the way an input appears—and the
attributes it uses or requires—depending on the
type attribute specified. But whatever the
type, the feature that’s common to all
input elements is that they allow users to enter
data.
The specific features of each kind of input are covered in the
type attribute
section of this reference. Other type-specific attributes are
indicated as such in their own sections.
Use This For …
The input
element is used to capture user information. The kind of control that’s
used will vary on a case-by-case basis, as explained in type.
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
It causes no compatibility issues, and has excellent support across all tested browsers.
In this Section
- accept
defines the types of files that may be uploaded - accesskey
assignment of a key to put focus on this form control - align
specifies the alignment or position of an imageinput - alt
defines alternative text for imageinputtypes - checked
preselects the checkbox or radioinputto which the attribute is applied - disabled
disables theinputso that it can’t be used - maxlength
defines the maximum length (in characters) that theinputcan accept - name
defines a name by which theinputcan be referenced - readonly
prevents theinputdata or selection state from being cleared or changed - size
specifies the width of input fields - src
defines the location (or source) of the image input - tabindex
indicates the order in the logical tabbing sequence for this control - type
defines the type of theinputcontrol - usemap
defines a client-side image map forinputelements of type"image" - value
sets the predefined value of the input control
Related Reading
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

