input (HTML element)
| Depr. | Empty | Version |
|---|---|---|
| No | Yes | HTML 2 |
| IE5.5+ | FF1+ | SA1.3+ | OP9.2+ |
|---|---|---|---|
| Full | Full | Full | Full |
Syntax
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.
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>
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
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.0 | 9.2 | 9.5 |
| Full | Full | Full | Full | Full | Full | Full | Full | Full | Full | 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 uploadedaccesskey
assignment of a key to put focus on this form controlalign
specifies the alignment or position of an imageinputalt
defines alternative text for imageinputtypeschecked
preselects the checkbox or radioinputto which the attribute is applieddisabled
disables theinputso that it can’t be usedmaxlength
defines the maximum length (in characters) that theinputcan acceptname
defines a name by which theinputcan be referencedreadonly
prevents theinputdata or selection state from being cleared or changedsize
specifies the width of input fieldssrc
defines the location (or source) of the image inputtabindex
indicates the order in the logical tabbing sequence for this controltype
defines the type of theinputcontrolusemap
defines a client-side image map forinputelements of type"image"value
sets the predefined value of the input control
User-contributed notes
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.