HTML The Definitive Guide (112 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
2.3Mb size Format: txt, pdf, ePub

/* Echo the parameters back to the user */

for(i = 0; i < num_entries; i++)

printf("

  • %s = %s\n", entries[i].name, entries[i].val);

    /* And close out with more boilerplate */

    printf("\n");

    printf("\n");

    printf("\n");

    }

    Again, we follow the same general form. The program starts by declaring the various utility routines needed to parse the parameters, along with a data structure to hold the parameter list. The actual code begins by reading the parameter list from the standard input and building a list of parameter names and values in the array named entries. Once this is complete, a boilerplate document header is written to the standard output, followed by the parameters and some closing boilerplate.

    Like the other examples, this program is handy for checking the parameters being passed to the server application while you are early in the forms and application debugging process. You can also use it as a skeleton for other applications by inserting appropriate processing code after the parameter list is built up and altering the output section to send back the appropriate results.

    10.10 Creating Effective

    11. Tables
    Forms

    Chapter 11
    11. Tables
    Contents:

    The HTML Table Model

    Table Tags

    New HTML 4.0 Table Tags

    Beyond Ordinary Tables

    Of all the extensions that originally had found their way into the HTML 3.2 standard and remain fully supported in the new HTML 4.0 standard, none is more welcome than tables. While HTML tables are useful for the general display of tabular data, they also serve an important role in managing document layout. Creative use of tables, as we'll show in this chapter, can go a long way to enliven an otherwise dull document layout. And you may apply all the HTML styles to the various elements of a table to achieve a desktop-published look and feel.

    11.1 The HTML Table Model

    The standard HTML model for tables is fairly straightforward: a table is a collection of numbers and words arranged and related in rows and columns of
    cells
    . Most cells contain the data values; others contain row and column headers that describe the data.

    Define a table and include all of its elements between the

    tag and its corresponding
    end tag. Table elements, including data items, row and column headers, and captions, each have their own markup tag. Working from top to bottom and left to right, you define, in sequence, the header and data for each column cell across the table, and progress down row by row.

    The latest HTML standard also provides an extended collection of tag attributes, which once were popular extensions to the language supported by the major browsers. They make your tables look good, including special alignment of the table values and headers, borders, and table rule lines, and automatic sizing of the data cells to accommodate their content. The various popular browsers have slightly different sets of table attributes; we'll point out those variations as we go.

    11.1.1 Table Contents

    You can put nearly anything you might have within the body of an HTML document inside a table cell, including images, forms, rules, headings, and even another table. The browser treats each cell as a window unto itself, flowing the cell's content to fill the space, but with some special formatting provisions and extensions.

    11.1.2 An Example Table

    Here's a quick example that should satisfy your itching curiosity to see what an HTML table looks like in source code and when finally rendered as in
    Figure 11.1. More importantly, it shows you the

    basic structure of a table from which you can infer many of the elements, tag syntax and order, attributes, and so on, and to which you may refer as you read the following various detailed descriptions:



















    Kumquat versus a poked eye, by gender

    Preference
    Eating KumquatsPoke In The Eye
    GenderMale73%27%
    Female16%84%

    Figure 11.1: HTML table example rendered by Netscape (top) and by Mosaic (bottom)

    11.1.3 Missing Features

    At one time, standard HTML tables didn't have all the features of a full-fledged table-generation tool you might find in a popular word processor. Rather, the popular browsers, Internet Explorer and Netscape in particular, provided extensions to the language.

    What was missing was support for running headers and footers, particularly useful when printing a lengthy table. Another was control over table rules and divisions.

    Today, the browsers are behind; HTML 4.0 has standardized the many extensions and introduced new solutions. It's the browsers that now need to catch up.

    10.11 Forms Programming

    11.2 Table Tags

  • Other books

    Second Chance Ranch by Audra Harders
    La plaza by Luis Spota
    Somebody Told Me by Stephen Puleston
    The Good Doctor by Paul Butler
    Dance With Me by Heidi Cullinan
    The Crooked Branch by Jeanine Cummins
    Protecting Her Child by Debby Giusti
    Devilishly Sexy by Kathy Love