http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-01.html
HTML fill-out forms can be used for questionnaires, hotel reservations, order forms, data entry, and a wide variety of other applications. The form is specified as part of an HTML document. The user fills in the form and then submits it. The user agent then sends the form's contents as designated by the Form element. Typically, this is to an HTTP server, but you also can e-mail form contents for asynchronous processing.
Forms are created by placing input fields within paragraphs, preformatted text, lists, and tables. This gives considerable flexibility in designing the layout of forms.
HTML 3.0 supports the following kinds of fields:
It is expected that future revisions to HTML will add support for audio fields, multirow entry of database tables, and extending multiline text fields to support a range of other data types, in addition to plain text. Client-side scripts will provide the means to constrain field values and to add new field types.
Every form must be enclosed within a Form element. Several forms can exist in a single document, but the Form element can't be nested. The browser is responsible for handling the input focus--which field currently will get keyboard input. Many platforms have existing conventions for forms--for example, pressing Tab and Shift+Tab to move the keyboard focus forward and backward between fields, and pressing Enter to submit the form.
The submitted contents of the form logically consist of a list of name/value pairs, where the names are given by the Name attributes of the various fields in the form. Each field normally will be given a distinct name. Several radio buttons can share the same name because this is how you specify that they belong to the same control group; at any time, only one button in the group can be selected.
The Action attribute is a URL specifying the location to which the contents of the form is submitted to elicit a response. If the Action field is missing, the URL for the document itself is assumed. The way in which data is submitted varies with the access protocol of the URL and with the values of the Method and Enctype attributes.
This attribute specifies the MIME content type to be used to encode the form contents. It defaults to the string
"application/x-www-form-urlencoded"
This specifies variations in the protocol used to send the form contents. It currently is restricted to GET (the default) or POST. The attribute was introduced to inform user agents which HTTP methods the server supports.
This can be used to give a URI for a script. The scripting language and the interface with the user agent is not part of the HTML 3.0 specification.
The Input element is used for a wide variety of entry fields within HTML fill-out forms. The Type attribute determines the type of field.
A checkbox field has two states: selected and unselected. Its name/value pair only appears in the submitted data when selected. Checkboxes are used for Boolean attributes. They also can be used for attributes that can take multiple values at the same time. This is represented by a checkbox for each optional value, with the same name for each of the checkboxes. Unselected checkboxes don't appear in the submitted data. Both Name and Value are required for checkboxes. To initialize the checkbox to its selected state, include the Checked attribute. Checkboxes provide an alternative to using the Select element for multiple-choice menus.
File attachments enable users to attach one or more files to be submitted with the form's contents. The Accept attribute can be used to specify a comma-separated list of MIME content types. These are used to restrict the kinds of files that can be attached to the form--for example,
<input name=pictures type=file accept="image/*">
This example restricts files to match "image/*" (to registered MIME image types). For Windows-based user agents, it is suggested that File fields display the name of the last file attached, with the capability to open a file dialog box to view the complete list of files attached so far. The Accept attribute then acts to specify the filter on the list of candidate files.
With hidden fields, no field is presented to the user, but the content of the field is sent with the submitted form. This value can be used to transmit state information about client/server interaction--for example, a transaction identifier. These fields are needed because HTTP servers don't preserve state information from one request to the next.
Image fields act like Submit buttons, but include the location where the user clicked on the image. The image is specified with the SRC attribute.
Password fields are the same as single-line text fields except that each character typed is echoed by a shadow character--an asterisk or the space character. The user can see how many characters have been typed but not what was typed.
Suitable for attributes that can take a single value from a set of alternatives. All radio buttons in the same group should be given the same name. Only the selected radio button in the group generates a name/value pair in the submitted data. Both Name and Value are required for radio buttons. To initialize the radio button to its selected state, include the Checked attribute. Radio buttons offer an alternative to using the Select element for single-choice menus.
Range fields enable the user to pick a numeric value between a lower and an upper bound. The range is specified with the Min and Max attributes, as in
<input name=rating type=range min=1 max=10>
If either the lower or upper bound is a real number, then the range is a real value; otherwise, it is restricted to integer values only. The Value attribute can be used to initialize the range field. It is an error for the value to lie outside the specified range. The default value is midway between the lower and upper limits.
When a Reset button is pressed, the form's fields are reset to their specified initial values. The label to be displayed on the button can be specified just as for the Submit button. Likewise, the SRC attribute can be used to specify a graphic.
The Scribble on Image fields enable the user to scribble with a pointing device (such as a mouse or pen) on top of a predefined image. The image is specified as a URI with the SRC attribute. If the user agent can't display images or can't provide a means for users to scribble on the image, then the field should be treated as a text field. The Value attribute can be used to initialize the text field for these users. It is ignored when the user agent provides Scribble on Image support.
Single-line text fields are used for entering short text strings, such as people's names, numbers, and dates. The visible width of the field in characters can be set with the Size attribute. When using a variable pitch font, the Size attribute sets the width in en units (half the point size).
The user should be able to enter more than this, with the contents of the field scrolling horizontally as needed. The Maxlength attribute can be used to specify the maximum number of characters permitted for the string.
If the Type attribute is missing, the Input element is assumed to be a single-line text field. The Name attribute is used to identify the field when the form's contents are converted to the name/value list.
The Value field can be used to initialize the text string. Character entities can be used include accented characters in this string.
Note: Use the Textarea element for multiline text entry fields.
When Submit buttons are pressed, they submit the form's data. You can use the Value attribute to provide a non-editable label to be displayed on the button. The default label is application-specific. A graphic can be specified for the Submit button using the SRC attribute.
The Submit button normally makes no contribution to the submitted data. The exception is when the field includes a Name attribute, in which case the Name and Value attributes are included with the submitted data. This can be used to distinguish which Submit button the user pressed.
The Accept attribute is a comma-separated list of MIME content types for use in restricting the types of files that can be attached to a form with a File field.
The Align attribute only applies to fields with background images--for example, Scribble, Image, Submit, or Reset fields. It is intended to provide the same positional control as for the IMG element. The Align attribute takes the values Top, Middle, or Bottom; this defines whether the top, middle, or bottom of the field should be aligned with the baseline for the text line in which the Input element appears.
For ALIGN=LEFT, the field floats down and over to the current left margin, and subsequent text wraps around the right-hand side of the field. For ALIGN=RIGHT, the field aligns with the current right margin and text wraps around the left.
The presence of the Checked attribute indicates that a radio button or checkbox should be initialized to its selected state.
Class is a space-separated list of SGML NAME tokens and is used to subclass tag names. By convention, the class names are interpreted hierarchically, with the most general class on the left and the most specific on the right, where classes are separated by a period. The Class attribute most commonly is used to attach a different style to some element, but it is recommended for cases in which practical class names should be picked on the basis of the element's semantics because this permits other uses, such as restricting searches through documents by matching on element class names. The conventions for choosing class names are outside the scope of this specification.
When present, the Disabled field should be rendered as normal, but can't be modified by the user. When practical, the rendering should provide a cue that the field is disabled, by graying out the text or changing the color of the background.
The Error attribute specifies an error message explaining why the field's current value is incorrect. When this attribute is missing, the field can be assumed to be okay. User agents are recommended to indicate that the field is in error.
ID is an SGML identifier used as the target for hypertext links or for naming particular elements in associated style sheets. Identifiers are Name tokens and must be unique within the scope of the current document.
This is one of the ISO standard language abbreviations--for example, "en.uk" for the variation of English spoken in the United Kingdom. Lang can be used by parsers to select language-specific choices for quotation marks, ligatures, hyphenation rules, and so on. The language attribute is composed from the two-letter language code from ISO 639, optionally followed by a period and a two-letter country code from ISO 3166.
The Max attribute is an integer or real number and specifies the upper bound for a range field.
The Maxlength attribute specifies the maximum number of characters permitted for Text and Password fields.
The MD attribute specifies a message digest or cryptographic checksum for the associated image specified by the SRC attribute. It is used when you want to be sure that the image is indeed the same one that the author intended, and hasn't been modified in any way--for example,
MD="md5:jV2OfH+nnXHU8bnkPAad/mSQlTDZ"
which specifies an MD5 checksum encoded as a base-64 character string. The MD attribute generally is allowed for all elements that support URI-based links.
The Min attribute is an integer or real number and specifies the lower bound for a range field.
Name provides a character string used to name the field when submitting the form's data. Several fields may share the same name--for example, a group of radio buttons or checkboxes. The name is case insensitive.
The Size attribute specifies the visible width of a Text or Password field. For fixed-pitch fonts, the Size attribute specifies the maximum number of characters visible; for variable-pitch fonts, the attribute specifies the width in en units (half the point size).
The SRC attribute specifies the URI for an image for use as the background of a Scribble, Image, Submit, or Reset field. Its syntax is the same as that of the HREF attribute of the <A> tag.
Defines the type of the field as one of the following: Text, Password, Checkbox, Radio, Range, File, Scribble, Hidden, Submit, Image, or Reset. It defaults to Text. The attribute value is an SGML name token and, as such, is case insensitive.
Value is a character string or number used to initialize text, range, and hidden fields.
To let users enter more than one line of text, use the Textarea element.
For example,
<TEXTAREA NAME="address" ROWS=64 COLS=6> HaL Computer Systems 1315 Dell Avenue Campbell, California 95008 </TEXTAREA>
The text up to the end tag is used to initialize the field's value. The initialization text can contain SGML entities--for accented characters, for example--but is otherwise treated as literal text. This end tag always is required even if the field is initially blank. When submitting a form, the line terminators are implementation dependent. Servers should be capable of recognizing a CR immediately followed by an LF, or separate CRs and LFs as all signifying the ends of lines. User agents should tolerate the same range of line terminators within the initialization text. In a typical rendering, the Rows and Cols attributes determine the visible dimension of the field in characters. The field is rendered in a fixed-width font. User agents should allow text to grow beyond these limits by scrolling as needed. The user agent is recommended to wrap words as they are entered, to fit within the Textarea field. It is further recommended that a means is provided for users to turn this feature off and on.
Note: In the initial design for forms, multiline text fields were supported by the Input element with TYPE=TEXT. Unfortunately, this causes problems for fields with long text values because SGML limits the length of attribute literals. The HTML 2.0 DTD allows for up to 1,024 characters (the SGML default is only 240 characters).
The Textarea tag uses the same attributes as the Input type except for the following additions.
Cols are the visible number of characters across the field. User agents should allow text to grow beyond these limits by scrolling as needed.
Rows gives the visible number of text lines shown by the field. User agents should allow text to grow beyond these limits by scrolling as needed.
The Select element is used for single- and multiple-choice menus. It generally is rendered as a drop-down or pop-up menu and offers a more compact alternative to using radio buttons for single-choice menus, or checkboxes for multiple choice menus as illustrated in the following code:
Example: <SELECT NAME="flavor"> <OPTION>Vanilla <OPTION>Strawberry <OPTION>Rum and Raisin <OPTION>Peach and Orange </SELECT>
This is a single-choice menu. When you want a multiple-choice menu, you need to include the Multiple attribute with the Select element-- for example,
<SELECT MULTIPLE NAME="flavor">
The Name attribute is used when creating the name/value list describing the form's contents. A name/value pair is contributed for each selected option. The value is taken from the Option's Value attribute and defaults to the content of the Option when the Value attribute is missing.
For single-choice menus, if no option initially is marked as selected, then the first item listed is selected. This is inappropriate for multiple-choice menus, though. HTML 3.0 extends the Select element to support graphical menus. This enables you to specify an image for the Select element and hot zones for each of the Option elements. In this way, the same menu can be rendered as a conventional text-based menu for non-graphical user agents and a graphical menu for graphical user agents. The image is specified in the same way as for IMG elements. This means that you can specify suggested values for the width and height. You also can float the image to the left or right margins and flow other elements around it. The hot zones for Option elements are specified using the Shape attribute in the same way as for anchor elements.
The Select tag uses the same attributes as the Input type, except for the following additions.
Height is the optional suggested height for the image. By default, this is given in pixels.
The presence of the Multiple attribute denotes that the Select element defines a multiple-choice menu. In its absence, the element defines a single-choice menu.
The SRC attribute is used for graphical menus to specify the URI for the image. Its syntax is the same as that of the HREF attribute of the <A> tag.
This optional attribute specifies the units for the width and height attributes. It is units=pixels (the default) or units=em (the width of the letter "m"), which scales with the font size.
Width is the optional suggested width for the image. By default, this is given in pixels.
The Option element can occur only within a Select element. It represents a possible choice. It can only contain text, together with SGML entities for accented characters. When the form is submitted, the name of the enclosing Select element is paired with the option's Value attribute to contribute a name/value pair for the selection. Unselected options don't contribute to the form's submitted data. You can initialize the option to its selected state by including the Select attribute.
When present, the Selected attribute signifies that the option should be initialized in its selected state. It is an error for more than one option to be selected for single-choice menus.