Example 1: Simple default table
Example 2: BORDER width
Example 3: BORDERCOLOR
Example 4: Background & Cell Colours
Example 5: Comparing CELLSPACING and CELLPADDING
Example 6: COLSPAN and ROWSPAN
Example 7: VALIGN and ALIGN
Example 8: Using COLS and Not Using COLS (Netscape Users Only)
Example 9: WIDTH Attributes
Example 10: Nesting Tables
a) COLSPAN |
|
Code:
<TABLE BORDER=5 BORDERCOLOR=#801010 CELLPADDING=10>
|
|||
b) ROWSPAN | |||||
|
Code:
<TABLE BORDER=5 BORDERCOLOR=#801010 CELLPADDING=10>
|
a) Horizontal Alignment | |||||||
|
Code:
<TABLE BORDER=5 BORDERCOLOR=#801010
|
||||||
b) Vertical Alignment | |||||||
|
Code:
<TABLE BORDER=5 BORDERCOLOR=#801010 CELLPADDING=10>
|
||||||
|
Code:
<TABLE BORDER=5 BORDERCOLOR=#801010 CELLPADDING=5>
|
NOTE: As mentioned before, the COLS attribute forces the columns to be of equal width. This attribute works only in Netscape. Compare the following two tables when with and without the COLS attribute included. | |||||||
a)Without COLS | |||||||
|
Code:
<TABLE BORDER=5 BORDERCOLOR=#801010 CELLPADDING=10>
|
||||||
b)With COLS | |||||||
|
Code:
<TABLE BORDER=5 BORDERCOLOR=#801010 CELLPADDING=10 COLS=2>
|
||||||
NOTE: Those with IE browsers can click here to see what the Netscape browsers see. |
a) Table Widths | |||||||
|
Code:
<TABLE WIDTH=300 BORDER=5 CELLPADDING=5 CELLSPACING=2> |
||||||
NOTE: Most people recommend defining your widths using pixels instead of percentages, as the percentages are in relationship to the size of the screen and the screen resolution (less control over look of page). If you want different columns (or cells) to have different widths, look at the following example: | |||||||
b) Cell Widths | |||||||
|
Code:
<TABLE WIDTH=300 BORDER=5 CELLPADDING=5 CELLSPACING=2> |
Putting one table into another table (or "nesting" the tables in programming lingo) is very easy to do. In fact, all the examples I have shown demonstrate how nesting looks. Each of the examples is in a table that is 85% of the screen size, with no border, and with padding within the cell of 10 pixels. (<TABLE WIDTH=80% BORDER=0 CELLPADDING=10>) I will show you another example of a nested table for your viewing pleasure along with the code, complete with as much of what we have just learned as I can possibly fit in. | |||||||||
|
Code:
<TABLE WIDTH=300 BORDER=5 CELLPADDING=5 CELLSPACING=0>
<TR> <TD>Cell 1a</TD><TD>Cell 1b</TD> </TR> <TR> <TD>Cell 1c</TD><TD>Cell 1d</TD> </TR> </TABLE> </TD> <TD BGCOLOR=#9A9ACD WIDTH=100 ALIGN=CENTER>&ly;B>Cell 2</B></TD> </TR> <TR> <TD BGCOLOR=#50AB45>Cell 3</TD>< /TR> <TR> <TD BGCOLOR=#DE1010>Cell 4</TD></TR> </TABLE> |
Return to the HTML Lesson Guide
Return to Tables Lesson
Read the next lesson: Frames