Tables are used in HTML pages to present information in a well-organized manner. The logical organization of a table is in columns and rows, along with headers of one sort or another. Take a look at the example below & it's corresponding HTML code:
| This is the table header | |
|---|---|
| This is the first element | This is the first element's definition |
| This is the second element | This is the second element's definition |
<center>
<table bgcolor="#F0F0F0" border=2>
<TH colspan = 2>This is the table header</TH>
<TR>
<TD>This is the first element</TD>
<TD>This is the first element's definition</TD>
</TR>
<TR>
<TD>This is the second element</TD>
<TD>This is the second element's definition</TD>
</TR>
</table>
</center>
In the HTML code above, the bgcolor="#F0F0F0" of the "table" tag sets the background color of the table to a light gray.
border=2 sets the border thickness of the table to a relative size of 2. In the TH tag, colspan=2 ensures that the table header itself will span the 2 columns of the table. Let's take a closer look at the tags that make up the cells of the table...
colspan attribute from the TH tag.
| This is the header | |
|---|---|
| First element | Second element |
So...if you wanted to have a table w/ a header, 3 rows, and 5 columns per row. You would need 5 TD entries per TR and 3 TR entries in the TH. Simple, huh?
bgcolor attribute of the TD tag for each cell.
There are a lot of attributes for each tag associated with table, so please see the Tag Index for more info.
Click here to return to the previous page.