-->
 |
The Tables feature first appeared in Netscape 1.1 and was a major advancement for control of page layout. Today they are considered the most essential item in Web page construction as they provide excellent control of white space. Pages that have good eye appeal and/or efficient use of space likely employ the Tables feature.

This tutorial is written to simplify the understanding and application of associated tags and related attributes. Only those tags that are common to both Netscape and IE browsers are addressed here. Enjoy.
|
|
Step-by-Step
- Basic Table
- Row & Column Span
- Table Borders
- Cell Spacing & Padding
- Table Bgcolor
-
- Content Alignment
- Table Captions
- Table Header
- Summary (Tables vs. Frames)
|
Basic Table (two rows, three columns each)
| |
<TABLE BORDER="1">
<TR>
<TD>Row1,Cell1</TD>
<TD>Row1,Cell2</TD>
<TD>Row1,Cell3</TD>
</TR>
<TR>
<TD>Row2,Cell1</TD>
<TD>Row2,Cell2</TD>
<TD>Row2,Cell3</TD>
</TR>
</TABLE>
|
|
| Row1,Cell1 |
Row1,Cell2 |
Row1,Cell3 |
| Row2,Cell1 |
Row2,Cell2 |
Row2,Cell3 |
|
- <TABLE> </TABLE>
- Table open and close tags. Border size is set at 1 pixel in the above example.
- <TR> </TR>
- Defines a table row.
- <TD> </TD>
- Defines table data and divides a row into cells.
Row & Column Span
These cell attributes enable the construction of a spreadsheet type layout. There is unlimited flexibility in the spanning of rows and columns that allows for customized display of data or columns of text with headers.
| |
<TABLE BORDER="1">
<TR>
<TD ROWSPAN="3">Row1, Cell1</TD>
<TD COLSPAN="3">Row1, Cell2</TD>
</TR>
<TR>
<TD>Row2, Cell1</TD>
<TD>Row2, Cell2</TD>
<TD ROWSPAN="2">Row2, Cell3</TD>
</TR>
<TR>
<TD>Row3, Cell1</TD>
<TD>Row3, Cell2</TD>
</TR>
</TABLE>
|
|
Row1 Cell1 |
Row1, Cell2 |
| Row2, Cell1 |
Row2, Cell2 |
Row2 Cell3 |
| Row3, Cell1 |
Row3, Cell2 |
|
- ROWSPAN="3"
- Instructs the browser how many rows the current cell should span. Here, the first cell spans three rows, its own row plus Row 2 and Row 3.
COLSPAN="3"
Instructs the browser how many columns the current cell spans. Here, Cell 2 of Row 1 spans the three cells (or columns) of Row 2.
ROWSPAN="2"
Here, Cell 3 of Row 2 spans two rows, its own row plus Row 3.
The foregoing two examples represent the fundamental Table tags, <TABLE>,
<TR>, <TD>, and how the combination of these are used for layouts. It is important to understand that tables are simply rows stacked on top of each other. Each row and
its contents are defined one at a time and displayed one after the other. It is also very important to understand how colspan and rowspan attributes of each row affect cells of succeeding rows. That was
my first hurdle as it seemed odd but the concept is very flexible once understood.

The remaining sections of this tutorial will deal with the tags
and attributes that provide options of border, padding, spacing, header, background color, caption and a few examples.

For purposes of clarity, only the tags and attributes will given with an example of its effect.
|
Table Borders
Table border width can be specified in pixels. It is wise to set borders equal to "1" while designing table layouts so that you can see what is going on. After being satisfied with placement of content and alignments, turn borders *off* (set border equal to "0") for a better, less cluttered presentation .

However, for tabulating numerical data it is sometimes useful to leave borders equal to "1". Another option is to use background color (discussed below) to highlight
alternate columns or rows.
|
<TABLE BORDER="1">
|
|
| Row1, Cell1 |
Row1, Cell2 |
| Row2, Cell1 |
Row2, Cell2 |
|
<TABLE BORDER="10">
|
|
| Row1, Cell1 |
Row1, Cell2 |
| Row2, Cell1 |
Row2, Cell2 |
|
Cell Spacing & Padding
Values of spacing and padding control the width in pixels of spaces between cells and how much padding is put between each cell boundary and its content.
Cell Spacing
<TABLE BORDER="1" CELLSPACING="10">
|
|
| Row1, Cell1 |
Row1, Cell2 |
| Row2, Cell1 |
Row2, Cell2 |
|
Cell Padding
<TABLE BORDER="1" CELLPADDING="10">
|
|
| Row1, Cell1 |
Row1, Cell2 |
| Row2, Cell1 |
Row2, Cell2 |
|
Table Background Colors
There are a selection of commands which allow you control over how a table is colored.
|
<TABLE BORDER="1" BGCOLOR="#FFFFCC">
This sets the background color for the whole table. Be considerate, choose background and text colors that provide high contrast for readability.
|
| Row1,Cell1 |
Row1,Cell2 |
| Row2,Cell1 |
Row2,Cell2 |
|
| You can also set background colors for the individual cells.
<TABLE BORDER="1">
<TR>
<TD BGCOLOR="#FFCCFF">Row1,Cell1</TD>
<TD BGCOLOR="#00FFFF">Row1,Cell2</TD>
</TR>
<TR>
<TD BGCOLOR="#FFFF99">Row2,Cell1</TD>
<TD BGCOLOR="#CCFFCC">Row2,Cell2</TD>
</TR>
</TABLE>
|
| |