Creating Tables

greenspun.com : LUSENET : Poesie d'Orient : One Thread

There are three main elements to a table. The <TABLE> tag, the table row <TR> and the table cell <TD>. Every time you add a TR tag, this means that you are dropping down to the next row. Every time you add a <TD> tag, then you are starting a new cell inside of that row. I have listed the main elements below, along with their most common attributes. <p> <TABLE> Attributes align - aligns the table to the left, center or right. bgcolor - defines the color of the background for the entire table. border - defines the width of the border in pixels. cellpadding - is the invisible space in between the content of the cell and the actual cell wall. cellspacing - is the actual space (in pixels) between the two cells. width - defines the width of the table in pixels or a percentage. EXAMPLE: <TABLE align="center" bgcolor="blue" border="2" cellpadding="5" cellspacing="2" width="90%"> <p> <TR> Attributes align - aligns the content of the row to the left, center or right. bgcolor - defines the color of the background for the row. valign - vertically aligns the content of the row to the top, middle or bottom. EXAMPLE: <TR align="right" bgcolor="red" valign=top> <p> <TD> Attributes align - aligns the content of the row to the left, center or right. background - places a background image inside of the table cell. bgcolor - defines the color of the background for the entire table. colspan - stretches the length of the cells to 2 or more cell lengths. height - defines the heights of the cell in pixels. nowrap - is an attribute to lock the content so that it all stays on the same line. rowspan - stretches the height of the cells to 2 or more cells. valign - vertically aligns the content of the cell to the top, middle or bottom. width - defines the width of the actual cell, in pixels or percentage. EXAMPLE: <TD align="right" background="back.gif" bgcolor="green" colspan="3" height="200" nowrap rowspan="2" valign="bottom" width="300">

-- (svillafania@geocities.com), October 23, 1998

Moderation questions? read the FAQ