Sams Teach Yourself HTML 4 in 24 Hours

Sams Teach Yourself HTML 4 in 24 Hours

By Dick Oliver

Creating a Form

Every form must begin with a <form> tag, which can be located anywhere in the body of the HTML document. The form tag normally has two attributes, method and action:

<form method="post" action="mailto:me@mysite.com">

Nowadays, the method is almost always "post", which means to send the form entry results as a document. (In some special situations, you may need to use method="get", which submits the results as part of the URL header instead. For example, "get" is sometimes used when submitting queries to search engines from a Web form. If you're not yet an expert on forms, just use "post" unless someone tells you to do otherwise.)

The action attribute specifies the address to which to send the form data. You have two options here:

The form in Figures 8.1 and 8.2 includes every type of input you can currently use on HTML forms (with one exception: the button tag is discussed in Hour 19, "Web Page Scripting for Non-Programmers" ). Figure 8.3 shows how the form in Figure 8.2 might look after someone fills it out. Refer to these figures as you read the following explanations of each type of input element.

08fig01.gif

Figure 8.1 All parts of a form must fall between the <form> and </form> tags.

08fig02.jpg

Figure 8.2 The form listed in Figure 8.1 uses nearly every type of HTML form input element.

08fig03.jpg

Figure 8.3 Visitors to your Web site fill out the form with their mouse or keyboard, and then click the Click Here to Submit button.

Share ThisShare This

Informit Network