What HTML Forms Are For

The essence of serving up useful information is relevancy and immediacy. But the best judge of the quality of your information is your audience. Wouldn't it be wonderful if your readers could give you feedback on your Web pages? Then they could tell you what parts they like, what they don't like, and what other things they'd like to see included in your site.

This is where HTML forms come into the picture. As it turns out, HTML supports a rich variety of input capabilities to let you solicit feedback. In this course you will discover the tags to use, the controls and inputs they enable, along with some layout considerations for building forms. You will get to see some interesting example forms to help you understand what HTML forms look like and how they behave. JavaScript also uses forms and their elements extensively, so if you plan on learning JavaScript in the future, you will want to become very familiar with forms.

What's in a Form?

When adding form support to a Web page, you include special tags that let you solicit input from users. You surround these tags with text that prompts user responses. You also include tags that gather the input and ship it to your Web server. Here's how the process works:

On a particular Web page, you include tags to set up a form and to solicit input from users. Some of your users will work their way through this material and provide the information that you want. This essentially amounts to filling out the form that you've supplied.

After users fill out your form, they can then direct their input to the program running on the Web sever. In most cases, they need to select a particular control, called SUBMIT, that gathers the information and sends it to the proper destination on your Web sever. The program running on the sever accepts the input information then decodes and interprets the contents for further action. A custom-built document is then sent to you and the user is sent to your "return page".

Forms involve two-way communication

The input-catching programs on your server rely on an interface between Web browsers and servers called the Common Gateway Interface (CGI). This interface codifies how browsers can send information back to the severs. It sets up the formatting for the user-supplied input information, so that forms-handling programs know what to expect and how to deal with what they receive.

The ACTION attribute in the <FORM> tag specifies a URL that indicates a specific CGI script or program that collects the form data that a user entered. Likewise, the METHOD attribute describes the way in which input data is delivered to a forms-handling program.

In this course, we will concentrate on the input side of HTML forms, that is, you find out how to build forms.

Tag! You're a Form

HTML includes several different classes of form tags. To begin with, all HTML forms occur within the <FORM>...</FORM> tags. The <FORM> tag also includes attributes that specify where and how to deliver input to the appropriate Web server.

Within the <FORM>...</FORM> tags, all other forms-related tags and text must appear. These tags include methods for:

  • Specifying input (the <INPUT> tag and its many attributes).

  • Setting up text input areas (the <TEXTAREA>...</TEXTAREA> tags).

  • Selecting values from a predefined set of possible inputs (the <SELECT>...</SELECT> tags).

  • Managing the form's content (using the SUBMIT attribute for INPUT to deliver the content to the server, or the RESET attribute to clear it's content, and start over).

Forms input tags support multiple ways to interact with users, including:

  • Creating text inputs fields, where users can type in whatever they want.

  • Generating pull-down menus, often called "pick lists" because they require making one or more selections from a set of predefined choices.

  • Creating labeled check boxes or radio buttons on-screen, which users can select to indicate choices. Check boxes allow multiple selections and radio buttons allow just one selection.

This may not sound like much, but when you combine it with the ability to prompt users for input with surrounding text, it provides a surprisingly powerful way to ask for information right on your Web page. Thus the real answer to the question at the beginning of this course: "What's in a form?" has to be: "Almost anything you want to put there!"

[Go Back one page]   [Next page]