Tsuni_Night


Lesson 1 - Getting Started Lesson 2 - Fonts & Color Lesson 3 - Comments Lesson 4 - Links
Lesson 5 - Pictures & Graphics Lesson 6 - Spacing Lesson 7 - Tables Lesson 8 - Forms

HTML HELP
Lesson 7 - Tables

Tables are something that are relatively simple, but can become complex quickly.  There are a number of various commands you can add to have a table show up in a certain way with a certain number of  cells and rows.
Attribute Value Description
align left
center
right
Aligns the table. Deprecated. Use styles instead.
bgcolor color or HEX code Specifies the background color of the table. You can used named colors or the HEX colors.  Please take a moment to view Lesson 2 for HEX and named colors.
border numerical  Specifies the border width. Example: border="0" to display tables with no borders.
height numerical Specifies the height of a table.  Example: height=20% or height=100
width numerical Specifies the width of the table Example: width=150  or width=100%
cellpadding numerical  Specifies the space between the cell walls and contents Example: Cellpadding=1
cellspacing numerical  Specifies the space between cells Example: Cellspacing=1
<table></table>   Specifies the beginning and ending tags.
<tr></tr>   Table Row Specifies rows the <TR> function should always come before the Table Cell function.  You can have multiple Table Cells ( <TD>) within a Table Row (<TR>) but when creating  a table, or specific row you  must specify the Table Row first.
<td></td>   This defines individual cells.  You can also declare alignment and background color or image in each cell.
rowspan numerical This is how many rows a cell takes up Example:  Rowspan=2.  In this example it will take up 2 rows in a column
colspan numerical This is how many columns a cell takes up. Example Colspan=3.  In this example it will take up 3 columns.

All tables start with the same information.
<table><tr><td></td></tr><table>
This is what the code above would look like.  It is a one cell table.

In most cases however one cell tables is not what people are looking for. So in this case I have shown some examples below on how you can alter your table to fit your needs and design preferences.  

This is what a two column table would resemble

Abvoe is a two cell table.  This is actually closer to what more people use, only with multiple rows. The code for this table would look like:

<table border="1" >
<tr>
<td>This is what a two cell</td>
<td >table would resemble</td>
</tr>
</table>
 

This is two row table. This only has two cells, but
this is how you make additional lines in your table

Above is a two row table.  This is another common table that allows various rows.  This is usually combined with multiple columns as well.  The code for this table would look like:

<Table>
<tr>
<td>This is two row table. This only has two cells, but</td>
</tr>
<tr>
<td>this is how you make additional lines in your table</td>
</tr>
</table>
 

Purple = Red
Blue

The code above is for a three cell table.  The table takes up two rows in the first column creating one column, and the second column uses both rows. Please note the rowspan="2".  This tells the first column to take up two rows, and allows the first cell to be larger than the other two.

<table border="1" >
<tr>
<td rowspan="2">Purple =</td>
<td >Red</td>
</tr>
<tr>
<td>Blue</td>
</tr>
</table>
 

Grocery List

Eggs Milk Butter
Bread Apples Sugar
Tomatoes Spaghetti Hamburger

The example above is for a 4 row 3 column table.  The title, in this case, takes up all three columns and is noted with the colspan="3".  The colspan tells the table that the cell in question should span three columns.  This allows the title to be centered over the items listed in the table.


<table border="1" width=300>
<tr>
<td colspan="3" >
<p align="center"><b>Grocery List</b></td>
</tr>
<tr>
<td align="center" >Eggs</td>
<td align="center" >Milk</td>
<td align="center" >Butter</td>
</tr>
<tr>
<td align="center" >Bread</td>
<td align="center" >Apples</td>
<td align="center" >Sugar</td>
</tr>
<tr>
<td align="center" >Tomatoes</td>
<td align="center" >Spaghetti</td>
<td align="center" >Hamburger</td>
</tr> 
</table>

In all of the examples it is important to remember how much space you would like a cell to take up.  This will become important when you need to figure out how many rows or columns you need a specific cell to take up. 

Top

[ Home ] [ Forums ] [ Tsuni ] [ Bryir ] [ HTML Help ] [ PayPal Help ] [ Zodiac ] [ Links ]