HTML and CSS Reference
In-Depth Information
order they are encountered. Disabled form fields will not be part of the tabbing index,
although read-only controls will be.
type
This attribute specifies the type of the form control. A value of
button
indicates a
general-purpose button with no well-defined meaning. However, an action can be
associated with the button by using an event handler attribute, such as
onclick
. A value of
checkbox
indicates a check box control. Check box form controls have a checked and
unchecked setting, but even if these controls are grouped together, they allow a user to
select multiple check boxes simultaneously. In contrast, a value of
radio
indicates a radio
button control. When grouped, radio buttons allow only one of the many choices to be
selected at a given time.
A form control type of
hidden
indicates a field that is not visible to the viewer but is
used to store information. A hidden form control often is used to preserve state information
between pages.
A value of
file
for the
type
attribute indicates a control that allows the viewer to
upload a file to a server. The filename can be entered in a displayed field, or a user agent
might provide a special browse button that allows the user to locate the file. A value of
image
indicates a graphic image form control that a user can click on to invoke an
associated action. (Most browsers allow the use of
img
-associated attributes such as
height
,
width
,
hspace
,
vspace
, and
alt
when the
type
value is set to
image
.) A value of
password
for the
type
attribute indicates a password entry field. A password field will not
display text entered as it is typed; it might instead show a series of dots. Note that
password-entered data is not transferred to the server in any secure fashion. A value of
reset
for the
type
attribute is used to insert a button that resets all controls within a form
to their default values. A value of
submit
inserts a special submission button that, when
clicked, sends the contents of the form to the location indicated by the
action
attribute of
the enclosing
<form>
tag. Lastly, a value of
text
(the default) for the
type
attribute
indicates a single-line text input field.
HTML5 expands greatly on this attribute's possible values, specifying
search
,
url
,
email
,
tel
,
datetime
,
date
,
month
,
week
,
time
,
datetime-local
,
number
,
range
, and
color
as well. Likely there will be others. Many of these ideas derived from the Web
Forms 2.0 specification, which Opera implements partially. WebKit also implements a select
number of these form field types. Likely other browsers will quickly follow suit.
usemap
This HTML 4.0 attribute is used to indicate the map file to be associated with an
image when the form control is set with
type="image"
. The value of the attribute should
be a URL of a map file but generally will be in the form of a URL fragment referencing a
map file within the current file.
value
This attribute has two different uses, depending on the value for the
type
attribute.
With data-entry controls (
type="text"
and
type="password"
), this attribute is used to
set the default value for the control. When used with check box or radio button form
controls, this attribute specifies the return value for the control. If it is not set for these fields,
a default value of
on
will be submitted when the control is activated.
vspace
This Internet Explorer-specific attribute indicates the vertical space, in pixels,
between the image and surrounding text when using
<input type="image">
.