CSCI 220: HTML Authoring & WWW Programming


Tables and Image Maps


What is A Table?

An HTML table arranges items in column/row fashion. Tables are great for creating event calendars, statistical summaries and other informational synopses. A good example of table usage in this fashion is my on-line syllabus. Besides the obvious usage of tables to display information which lends itself to a tabular format, there are many other ways to put tables to good use. If you cannot find a "standard" way of arranging things just the way you want them, using a table is a great workaround and will usually give you the results you want to achieve. For example, tables are a great way to maximize page space. Given an extremely long list of items, using ordinary list syntax would not allow one to display the entire list on a single page. This is something not terribly convenient for the reader. With a table, however, you can create a list which spans multiple columns, thus allowing the reader to see most, if not all items simultaneously.

Tables come in two primary flavors: those with borders and those without. A border is kind of the opposite of a horizontal rule: it gives a "framed" appearance rather than a chiseled, indented look. One of my favorite uses of tables is to "frame" large pictures. I simply create a single-item table consisting of the graphical image that I want to "frame", specify the size of my border and voila! I have a picture which appears to be framed into the page. Use of borders as an aesthetic tool is kind of subjective, but I generally use borders when trying to graphically display information in an ordered fashion. When I am using table more for "formatting" purposes, such as in the list example, borders are unnecessary and may even detract from the effect I am trying to achieve.

One of the other advantages of using tables is that they help you work around formatting limitations in "standard" HTML. For example, say you have two images, one tall and narrow, and the other short and wide, and you want to situated them so that the shorter image is to the side of the taller image and centered. You might try using the "absmiddle" attribute for the taller image, but you will find that that won't do the job. The bottom of the shorter image will be centered with the taller one. One workaround is to create a two-item, two-column table, with each column holding an image, and then specifying that the vertical alignment in each data item is to be middle. By omitting the border syntax, the images will be aligned correctly without any external indication that a table was used.


How Do I Create A Table?

The syntax for creating a table is fairly straightforward. However, using these simple construct, some fairly complex tables can be created. The best way to become handy with tables is to simply work through some examples. Examine the table below, then use the view source feature of your browser to examine how it works

A simple example of table creation in HTML

My Schedule

time/day Monday Tuesday Wednesday Thursday Friday
AM Laundry Meeting Groceries Study Party
PM HTML class Study HTML class Study Party

Four Primary Elements To a Table:

  1. Table <table></table>
    Options:
    1. border = #
    2. cellspacing = #
    3. cellpadding = #
    4. width = #
    5. hspace = #
    6. vspace =#

  2. Row <tr></tr>

  3. Column

  4. Caption <caption></caption>
    Options:
    1. align = top, bottom

  5. Heading <th></th>
    Options:
    1. valign = top, middle, bottom
    2. align = right, left, center, justify, decimal

  6. Data Item <td></td>
    Options:
    1. valign = top, middle, bottom
    2. align = right, left, center, justify, decimal
    3. colspan = #
    4. rowspan = #
    Notes on table design:

    Image Maps


    Lab Assignment

    Make a file that includes a table.
    Guidelines for the table Extra Credit (five points worth!)



    © 1996, Ted D. Biggs, Andy Harris
    Dept. of Computer and Information Science,
    Indiana University, Purdue University, Indianapolis
    Email: tbiggs@klingon.iupucs.iupui.edu