|[Next]||The Information Commons|
.................... Introduction to HTML
HTML Tables are contained within a TABLE element. The TABLE element denotes the range of the table, and defines properties of it. For example, the attribute BORDER indicates that the table should be drawn with a border around it and between each of the table's cells -- in the notation of tables, each box within the table is called a cell. In fact, BORDER is the only attribute supported by HTML 3 tables. The Netscape Navigator browser supports several other attributes, discussed a bit later.
The only two elements allowed inside a table are CAPTION, and TR. CAPTION defines a table caption, and can take one attribute -- ALIGN -- to define where the caption should be placed. Possible values are "top", "bottom" "left" and "right".
TR defines a Table Row -- a table is composed of any number of rows. Each row in turn contains TD (table data) or TH (table header) cells. The number of TD or TH elements defines the number of columns in the table, while the number of TR elements defines the number of rows. In general, TD elements are used for data, while TH elements are used for row or column headings.
Here is a simple table example, -- a table with 3 rows and 4 columns
This table is displayed as:
|Heading 1||Heading 2||Heading 3||Heading 4|
- TH, TD and TR often do not need end tags
The TD and TH elements usuallydo not need end tags (see below..). However, you can always put them in, and it is safest to do so -- the Netscape table formatter often gets confused if an end tag is missing. In particular> you should always use end tags if you have a TABLE within a TABLE -- in this situation, the table parser gets hopelessly confused if you don't close your TH, TD and TR elements. (Thanks to Daniel Paluska for pointing this out).
- The default TABLE has no borders
By default, tables are drawn without border lines. You need the BORDER attribute to draw the lines.
- By default, a table is flush with the left margin
TABLEs are plopped over on the left margin. If you want centered tables, you're out of luck -- unless you are using the Netscape browser. In this case you can center a table on the screen by placing it inside a <CENTER> .. </CENTER> element.
Netscape 2.0 supports table alignment, using the ALIGN attribute. Allowed values are "left" or "right", for example: <TABLE ALIGN="left">. The values "left" and "right" float the table to the left or right of the page, with text flow allowed around the table. This is entirely equivalent to IMG alignment.
|[Next]||.................... Introduction to HTML|
|Page Last Updated: 5 April 1996|