|
Let's begin with the most basic table we can make, and step by step build upon it and note the effect each of the attributes has on the table.. |
THIS IS THE CODE COLUMN |
THIS IS THE RESULTS COLUMN ATTEMPTING TO MIMIC A WEB-PAGE. |
The single data cell table shown below is the most basic table one can make. |
<table>
<tr>
<td>Not much but hold on.</td></tr></table> |
|
The table code below yielded a single row 2 column table. |
<table>
<tr>
<td>cell-1 </td>
<td>cell-2 </td></tr></table> |
|
A 2 row 3 column table. |
<table>
<tr>
<td>cell-1</td> <td>cell-2</td><td>cell-3 </td></tr> <tr>
<td>cell-4</td> <td>cell-5</td><td> cell-6 </td></tr> </table> |
cell-1 | cell-2 | cell-3 |
cell-4 | cell-5 | cell-6 |
|
The table with a border added. |
<table BORDER="5"><tr>
<td>cell-1</td> <td>cell-2</td><td>cell-3 </td></tr> </table> |
|
CELLSPACING creates a space around data cells. |
<table border="5" CELLSPACING="15"><tr>
<td>cell-1</td> <td>cell-2</td><td>cell-3 </td></tr> </table> |
|
CELLPADDING expands the space around the data cells. |
<table border="5" CELLPADDING="15"><tr>
<td>cell-1</td> <td>cell-2</td><td>cell-3 </td></tr> </table> |
|
Notice that up to now the table is against the left side of the page. That is because the table alignment is to the left by default. We can align the table to the "center" and to the "right" of the page as well. Below the table is aligned to the center of page. |
<table ALIGN="CENTER" border="5" ><tr>
<td>cell-1</td> <td>cell-2</td><td>cell-3 </td></tr> </table> |
|
The table WIDTH defines width in terms of screen resolution. Example; if your screen width resolution is set to 800 pixels a specified table width of 800 will fill the width of the screen. A width specified in percent of 100% will do the same. |
<table WIDTH="300" border="5"><tr><td>Width= 300 pixels</td></tr></table>
|
|
Cell WIDTH and HEIGHT fixes and preserves a uniform width and height independant of content. |
<table width="360" border="5"><tr><td HEIGHT="40" WIDTH="100">cell-1</td> <td HEIGHT="40" WIDTH="100" >cell-2</td><td HEIGHT="40" WIDTH="100">cell-3 </td></tr></table>
|
|
Just as the table can be aligned with respect to page, so can the data cell content can be aligned with respect to cell. The default cell alignment is to the left. |
<table width="360" align="left" border="5" ><tr><td ALIGN="CENTER" width="100">cell-1</td> <td ALIGN="CENTER" width="100">cell-2</td><td ALIGN="CENTER" width="100">cell-3 </td></tr> </table> |
|
Data cell content aligned right. |
<table width="360" align="left" border="5" ><tr><td ALIGN="RIGHT" width="100">cell-1</td> <td ALIGN="RIGHT" width="100">cell-2</td><td ALIGN="RIGHT" width="100">cell-3 </td></tr> </table> |
|
The data within a cell can also be aligned verticaly. Notice cell-1 was repeated 3 times in order to create sufficient height to notice the effect. |
<table width="360" border="5" cellpadding="0"><tr>
<td VALIGN="TOP">cell-1<BR>cell-1<BR>cell-1<BR></td> <td VALIGN="MIDDLE">cell-2</td><td VALIGN="BOTTOM">cell-3 </td></tr> </table>
|
cell-1 cell-1 cell-1
| cell-2 | cell-3 |
|
Colspan controls how many columns a cell will span. Here is a good place to also demonstrate the effect of the <TH> attribute. This attribute is similar to the <TD> attribute it differs in that it renders bold text. |
<table width="360" align="left" border="5"><tr>
<TH COLSPAN="3" align="center">A HEADLINE FOR COLSPAN.</TH></tr><tr>
<td>cell-1 </td> <td>cell-2</td><td>cell-3</td></tr></table> |
A HEADLINE FOR COLSPAN. |
cell-1 | cell-2 | cell-3 |
|
Rowspan controls how many rows a cell will span. |
<table width="360" align="center" border="5"><tr> <td colspan="4" align="center">THIS CELL SPANS 4 COLUMNS.</td></tr>
<tr>
<td>cell 1 </td> <td>cell 2</td>
<td ROWSPAN="2">THIS CELL SPANS 2 ROWS
<td>cell 3 </td> </tr><tr>
<td>cell 4</td> <td>cell 5</td>
<td>cell 6</td></tr></table>
|
THIS CELL SPANS 4 COLUMNS. |
cell 1 | cell 2 |
THIS CELL SPANS 2 ROWS
| cell 3 |
cell 4 | cell 5 |
cell 6 |
|
How about some color! Yes a table can have a background color "BGCOLOR". |
<table width="360" BGCOLOR="LIGHTSALMON" align="center" border="5"<tr>
<td colspan="3" align="center">A table with "LIGHTSALMON" background.
</td></tr><tr>
<td>cell-1 </td> <td>cell-2</td><td>cell-3</td></tr></table>
|
A table with "LIGHTSALMON" background.
|
cell-1 | cell-2 | cell-3 |
|