home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Book HomeWeb Design in a NutshellSearch this book

Chapter 15. Forms

Forms provide a method for true interaction between users and the publisher of a web site, with an immediacy that could never be achieved in print. With forms, you can solicit input from a user in order to provide a customized response on-the-fly or just collect the data for later use. Forms can be used for functions as simple as surveys and guestbooks or as complex as online commerce systems.

This chapter provides a detailed review of the available form elements and how to use them. It also provides a brief introduction to CGI, one of the available methods for processing form information.

15.1. Summary of Form Tags

In this section, browser support for each tag is noted to the right of the tag name. Browsers that do not support the tag are grayed out. Tag usage is indicated below the tag name. Start and end tags are required unless otherwise noted. "Deprecated" means that the tag or attribute is currently supported but is due to be phased out of the HTML specification and is discouraged from use (usually in favor of similar style sheet controls). The attributes listed for each tag reflect those in common use. A more thorough listing of attributes for each tag, according to the HTML 4.01 specification, appears in Appendix A, "HTML Elements".

<fieldset>NN 6 MSIE 4, 5.5, 6 HTML 4.01 Opera5

<fieldset> ... </fieldset>

Groups related controls and labels. The proper use of this tag should make documents more accessible to nonvisual browsers. It is similar to <div> but is specifically for grouping fields. It was introduced to improve form accessibility to users with alternative browsing devices.

<form>NN 2, 3, 4, 6 MSIE 2,3, 4, 5.5, 6 HTML 4.01 WebTV Opera5

<form> ... </form>

Indicates the beginning and end of a form. There can be more than one form in an HTML document, but forms cannot be nested inside one another, and it is important that they do not overlap.



Specifies a comma-separated list of file types (MIME types) that the server will accept and is able to process. Browsers may one day be able to filter out unacceptable files when prompting a user to upload files to the server, but this attribute is not yet widely supported.

accept-charset=charset list

Specifies the list of character encodings for input data that must be accepted by the server in order to process the current form. The value is a space- and/or comma-delimited list of ISO character set names. The default value is unknown. This attribute is not widely supported.


Required. Specifies the URL of the application that will process the form. The default is the current URL.


Specifies how the values for the form controls are encoded when they are submitted to the server when the method is post. The default is the Internet Media Type (application/x-www-form-urlencoded). The value multipart/form-data should be used in combination with the file input element.


Specifies which HTTP method will be used to submit the form data. With get (the default), the information is appended to and sent along with the URL itself.


Specifies a target for the results of the form submission to be loaded so results of a form can be displayed in another window or frame. The special target values _bottom, _top, _parent, and _self may be used.

<legend>NN 6 MSIE 4, 5.5, 6 HTML 4.01


Assigns a caption to a <fieldset> (it must be contained within a <fieldset> element). This improves accessibility when the fieldset is rendered nonvisually.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.