Components of a Table
[Previous] [Main] [Next]

 
Tables were introduced in HTML 3.0. While supported by browsers from major companies such as Netscape and Microsoft, there are still many browsers in use that have partial or even no support for tables.  
 
Tables have many uses, and are a great way to line up text and graphics, including producing multi-column pages that mimic newspaper layouts. Tables are also often used to present reports, menus, and countless other types of information.  
 
Manually coding HTML tables is among the most error prone aspects of web page design, and can become quite tedious or downright difficult for complex pages, especially ones with nested tables. However, using html++ removes such drudgery and lets you concentrate on producing the desired look and feel for your documents. By combining objects in a logical and precise manner, you'll never have to worry about lining up <TABLE></TABLE> tags again.  
 
Tables are composed of rows (the <TR> tag) and cells (the <TD> tag). A table can optionally have a caption, and row or column headings can also be specified.  
 
There are many options available for customizing the appearance of a table, including width, overall alignment on the page, foreground and background color, presence/absence of borders, and spacing within and between cells. You can also control the appearance of individual rows and cells, specifying alignment of their content, and even their foreground and background colors as well.  
 
html++ provides several classes for building tables:  
  • htmlTable
  • htmlTableCaption
  • htmlTableHeading
  • htmlTableRow
  • htmlTableCell
 
Of the five classes listed above, the most frequently used ones are htmlTable, htmlTableRow, and htmlTableCell. Examine closely the methods and examples for each of the classes. You'll find them to be among the most useful of html++ classes for your applications.  
 
Note that row/column headings, created using htmlTableHeading, are essentially bold-print cells. You could achieve the same effect by using regular htmlTableCell objects with specially-formatted text. Likewise, table captions can also be achieved by outputting properly formatted text in advance of the table on a page.  
 
html++ let's you do several interesting things not possible with traditional coding techniques. For example, let's say you want to produce a report based on a recordset from a database. A table is the logical choice for displaying the information.  
 
A common feature of such reports is to include a count of matching records at the top of the report. Using html++, you can create the table of the search results in an htmlTable object and hold it in memory. Once the object is built, you could output the record count to the page, then follow it with the contents of the table object. The result would be as though the record count were produced first, but your application only had to make one pass through the database to create the document.  
 
Another common application is to build table components in advance, then selectively include them in documents as necessary. For example, you might assemble separate htmlTable objects containing lists or reports (such as in a shopping cart application), then output them as needed based on selection criteria from a form.  
 


©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.