input

Level: 2

The input element represents a field whose contents may be edited by the user. It has these attributes.

align

Vertical alignment of the image - for use only with type=image. The possible values are exactly the same as for the align attribute of the <img> element.

checked

Indicates that a checkbox or radio button is selected. Unselected checkboxes and radio buttons do not return name/value pairs when the form is submitted.

maxlength

Indicates the maximum number of characters that can be entered into a text field. This can be greater that specified by size, in which case the field will scroll appropriately. The default is unlimited.

name

Symbolic name used when transferring the form's contents. This attribute is required for most input types and is normally used to provide a unique identifier for a field, or for a logically related group of fields.

size

Specifies the size or precision of the field according to its type. For example, specify input type text size="24" to specify a field with a visible width of 24 characters.

src

A URL or URN specifying an image - for use only with type=image.

type

Defines the type of data the field accepts. Defaults to free text. Several types of fields can be defined with the type attribute:

checkbox

Used for simple Boolean attributes, or for attributes which can take multiple values at the same time. The latter is represented by a number of checkbox fields each of which has the same name. Each selected checkbox generates a separate name/value pair in the submitted data, even if this results in duplicate names. The default value for checkboxes is on.

hidden

No field is presented to the user, but the content of the field is sent with the submitted form. This value may be used to transmit state information about client/server interaction.

image

An image field upon which you can click with a pointing device, causing the form to be immediately submitted. The coordinates of the selected point are measured in pixel units from the upper left corner of the image, and are returned (along with the other contents of the form) in two name/value pairs. The x-coordinate is submitted under the name of the field with .x appended, and the y-coordinate is submitted under the name of the field with .y appended. Any value attribute is ignored. The image itself is specified by the src attribute, exactly as for the img element.


NOTE:
In a future version of the HTML standard, the image functionality will be folded into an enhanced submit field.

radio

For attributes which can take a single value from a set of alternatives. Each radio button field in the group should be given the same name. Only the selected radio button in the group generates a name/value pair in the submitted data. Radio buttons require an explicit value attribute.

reset

This is a button that when pressed resets the form's fields to their initial values as specified by the value attribute.

submit

This is a button that when pressed submits the form. You can use the value attribute to provide a (non-editable) label to be displayed on the button (the default label is application-specific).

The name attribute is not required; a submit button only contributes a name/value pair to the submitted data if it has a name and was the button that was pressed in order to submit the form.

text

Single line text entry fields. Use in conjunction with the size and maxlength attributes. Use the textarea element for text fields which can accept multiple lines.

value

The initial displayed value of the field, if it displays a textual or numerical value; or the value to be returned when the field is selected, if it displays a Boolean value. This attribute is required for radio buttons.


Preceding Section:
form
Following Section: option
Parent Section: Forms and Input fields
Contents of HyperText Markup Language