[Previous] [Contents] [Next]


Other Elements Within Elements


You also might want to incorporate form fields within other types of tags. This is easily done by combining the HTML for your special tags together with the output from these methods to produce formatted forms. This section discusses these approaches to work around some limitations. Using Tables for Better Field Layout One major drawback in HTML is the lack of ability to align fields. Suppose you wish to lay out your fields along a grid. If you desire this kind of effect, the trick is to use tables, which are available in HTML 3.2. Tables are defined using the <TABLE> and </TABLE> tags. Rows within a table are defined using the <TR> and </TR> tags. Columns within the row are defined using the <TD> and </TD> tags. Header columns within the row are defined using the <TH> and </TH> tags. Let's take the restaurant questionnaire form and make it look a bit nicer using a table. Although the <TABLE> tag provides a BORDER option, you probably won't want to use borders around your form fields. Borders are more suitable for displaying a table of data. The text prompts should go in the first column, and the others should go in the second column. You no longer need the line breaks because these are inferred by the table row definitions. The Perl code will now look something like Listing 4.4.

[Previous] [Contents] [Next]