This document describes tags used to design and implement interactive
forms on a web page.
This table:
Support: |
2.0,
3.0, 3.2 |
1.1+ |
1.0+ |
and these icons:
alert you to tags and attributes that are not supported by all
browsers.
<FORM ACTION= action base>
form tags </FORM> <FORM
METHOD= method> form
tags </FORM> <FORM ENCTYPE= media
type> form tags </FORM>
<FORM ACTION= action base
TARGET= "target window name">
form tags </FORM>
<FORM SCRIPT= URL> form
tags </FORM>
The form tag introduces a form, which is made up of INPUT
elements, described in the sections that follow. A form may be inside structural
HTML tags and may also contain structural tags. Using tables and other elements
a form can take on various shapes and looks.
The ACTION
attribute defaults to the document's base address.
The METHOD attribute can be GET or
POST. GET specifies a query form, used to get data
from a server. POST specifies a form that gives information to the
server and perhaps causes a database to be updated or a message to be sent.
The SCRIPT attribute points to a script to be run. The browser
must be able to run the type of script that is specified.
The default media type
is 'application/x-www-form-urlencoded', which specifies how the browser puts
the user responses on the form together to form a response URL that is then
submitted to the server. For more on the CGI compliant
scripts that process the form, check the CGI documentation.
If
Target is specified then the output document will be loaded into the window
specified by "target window name". The following are the
predefined target names:
_blank
- Will cause the link to be loaded into a new blank window.
_self
- Will cause the link to be loaded into the same window the link was in.
_parent
- Will cause the link to be loaded into the parent of this document.
_top
- Will cause the link to be loaded into the full body of this window.
<INPUT TYPE=CHECKBOX NAME= name
VALUE= value> <INPUT TYPE=CHECKBOX
NAME= name VALUE= value
CHECKED>
The checkbox type input tag specifies a boolean choice
within the form that contains it. If more than one checkbox appears in the form
with the same name the user can select none, one or several of the choices. The
NAME attribute is a required field and is used to identify the data
for the field. The VALUE attribute specifies the value that is
returned if the box is checked. If the CHECKED attribute is
specified, the box is initially selected.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=FILE NAME= name
ACCEPT= mime type list>
The file type input tag allows the user to attach one or more files to the
form for submission. The NAME attribute is a required field and is
used to identify the data for the field. The ACCEPT attribute is a
list of mime types that will be accepted. (e.g. "image/*" or "image/gif,
image/jpeg").
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=HIDDEN NAME= name
VALUE= value>
The hidden type input tag specifies a hard coded name-value pair within the
form. This field is not displayed to the user. Both NAME and
VALUE are required attributes.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=IMAGE NAME= name
SRC= "URL">
<INPUT TYPE=IMAGE NAME= name
SRC= "URL"
ALIGN= "alignment">
The image type input tag specifies an image to be presented to the user. As
soon as the user clicks on the image, the form is submitted with the selected x
y coordinates of the spot on the image and the data for the other form fields.
The NAME attribute is a required field and is used to identify the
data for the field. The SRC and ALIGN attributes are
the same as in the Inline Image
tag.
The ALIGN attribute is used for image alignment and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
The
3.0 specification added two new attributes: DISABLED, and
ERROR. The DISABLED attribute shows the field but will
not allow the user to modify it. The ERROR attribute is used to
supply an error message for the field.
<INPUT TYPE=PASSWORD NAME= name>
<INPUT TYPE=PASSWORD NAME= name
MAXLENGTH= length> <INPUT TYPE=PASSWORD
NAME= name SIZE= size>
<INPUT TYPE=PASSWORD NAME= name
VALUE= value>
The password type input tag specifies a single line text entry field within
the form that contains it. The value entered by the user will be obscured as it
is entered. The NAME attribute is a required field and is used to
identify the data for the field. The MAXLENGTH attribute specifies
the number of characters that can be entered into this field. If
MAXLENGTH is not specified then there is no limit on the number of
characters entered. If MAXLENGTH is longer than SIZE
then the text field will scroll appropriately. The SIZE attribute
specifies the amount of display space this field should take up. The default for
SIZE will vary by browser. The VALUE attribute
specifies the initial value of the field.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=RADIO NAME= name
VALUE= value> <INPUT TYPE=RADIO
NAME= name VALUE= value
CHECKED>
The radio button type input tag allows a choice among a number of options.
Normally more than one radio button will appear in the form with the same name.
The user can then select only one of the of the choices. The NAME
attribute is a required field and is used to identify the data for the field. If
one of the choices has the CHECKED attribute it will initially be
selected. If none of the choices has the CHECKED attribute then the
first one defaults as initially selected. The VALUE attribute
specifies the value that is returned if the box is checked.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=RANGE NAME= name
MIN= min MAX= max>
<INPUT TYPE=RANGE NAME= name
MIN= min> MAX= max
VALUE= value>
The range type input tag allows the user to enter an number restricted to a
set range. The NAME attribute is a required field and is used to
identify the data for the field. The MIN and MAX
attributes specify the minimum and maximum values that can be entered. If either
MIN or MAX is a real number then the user can enter
real numbers, otherwise only integers can be entered. The VALUE
attribute specifies an initial value and should be in the range specified.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=RESET>
The reset type input tag specifies a button. When the user clicks the button,
all the fields in the form are reset to their initial values.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=SCRIBBLE NAME= name
SRC= URL VALUE= text>
The scribble type input tag allows the user draw on a predefined image. The
NAME attribute is a required field and is used to identify the data
for the field. The SRC attribute specifies the URL of the image.
The VALUE attribute specifies a text string that is used as an
alternate if images or scribbling are not supported by the browser.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=SUBMIT> <INPUT TYPE=SUBMIT
NAME= name> <INPUT TYPE=SUBMIT
VALUE= value>
The submit type input tag specifies a button. When the user clicks the
button, the form is submitted. The NAME attribute is used to
identify the data for the field. If no NAME attribute is given then
this element does not form part of the submitted response. The
VALUE attribute specifies the label for the button.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<INPUT TYPE=TEXT NAME= name>
<INPUT TYPE=TEXT NAME= name
MAXLENGTH= length> <INPUT TYPE=TEXT
NAME= name SIZE= size>
<INPUT TYPE=TEXT NAME= name
VALUE= value>
The text type input tag specifies a single line text entry field within the
form that contains it. The NAME attribute is a required field and
is used to identify the data for the field. The MAXLENGTH attribute
specifies the number of characters that can be entered into this field. If
MAXLENGTH is not specified then there is no limit on the number of
characters entered. If MAXLENGTH is longer than SIZE
then the text field will scroll appropriately. The SIZE attribute
specifies the amount of display space this field should take up. The default for
SIZE will vary by browser. The
VALUE attribute specifies the initial value of the field.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<SELECT NAME= name>
option entries </SELECT> <SELECT
NAME= name MULTIPLE> option
entries </SELECT> <SELECT
NAME= name SIZE= size>
option entries </SELECT>
<SELECT NAME= name
SRC= URL WIDTH= width
HEIGHT= height
UNITS= units> option
entries </SELECT> <OPTION>
content <OPTION SELECTED>
content <OPTION
VALUE= value> content
<OPTION SHAPE= shape>
The select tag specifies a multiple line selection box field within the form
that contains it. The user can select one or more lines if the attribute
MULTIPLE is specified. The NAME attribute is a
required field and is used to identify the data for the field. The
SIZE attribute specifies the number of lines of selections that are
to be displayed. The SELECTED attribute of the option tag
specifies that the option is to be initially selected. The VALUE
attribute specifies the value to be returned if this option is selected. If the
VALUE attribute is not specified the content of the option is used.
The
select tag's SRC, WIDTH, HEIGHT, and
UNITS attributes and the option tag's SHAPE attribute
define an image map. These attributes are the same as the ones described in the Figure tag.
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT.
<TEXTAREA NAME= name COLS= #
columns ROWS= # rows>
content </TEXTAREA> <TEXTAREA
NAME= name COLS= # columns
ROWS= # rows
WRAP =type>
content </TEXTAREA>
The text area tag specifies a multiple line text area field within the form
that contains it. The NAME attribute is a required field and is
used to identify the data for the field. The COLS attribute
specifies the width in characters of the text area. The ROWS
attribute specifies the number of lines the text area contains. The content is
used as an initial value for the field. The field can be scrolled beyond the
COLS and ROWS size to allow for larger amounts of text
to be entered. The wrap attribute can have values of OFF ,
SOFT and HARD .
The
3.0 specification adds three new attributes: DISABLED,
ERROR, and ALIGN. The DISABLED attribute
shows the field but will not allow the user to modify it. The ERROR
attribute is used to supply an error message for the field. The
ALIGN attribute is used to position the field and can be one of
TOP, BOTTOM, MIDDLE, LEFT or
RIGHT. |