More Table Attributes
On this page we are going to show what the table code looks like, and right after that the actual way the table will display. The <table> tag has several attributes that you can use to define it. They are cellspacing, cellpadding, border bordercolor and either background or bgcolor (background color) The latter two attributes are used the same as they are in the body tag.
This tag:
<table width="500" cellspacing="0" cellpadding="0" border="1" bgcolor="#c0c0c0">
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
The border above is set to 1.
This tag:
<table width="500" cellspacing="5" cellpadding="0" border="1" bgcolor="#c0c0c0">
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
The border above is set to 1 still, but we have added cellspacing="5" to the tag. Notice the difference.
This tag:
<table width="500" cellspacing="5" cellpadding="5" border="1" bgcolor="#c0c0c0">
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
Now we've added cellpadding="5" to this tag. Now the type moves away from the border.
This tag:
<table width="500" cellspacing="5" cellpadding="0" border="5" bgcolor="#c0c0c0">
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
Now the border="5" makes a heavier border on this table.
This tag:
<table width="500" cellspacing="5" cellpadding="0" border="1" background="background1.gif">
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
Here a background image is used within the table.
This tag:
<table width="500" cellspacing="5" cellpadding="0" border="1" bgcolor="#c0c0c0" bordercolor="#ff0000">
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
Here a background color is used, as well as a border color.
This tag:
<table width="500" cellspacing="0" cellpadding="5" border="1" bgcolor="#c0c0c0" bordercolor="#ff0000">
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
The bordercolor does not work in all browsers and should probably be steered away from. However it does work in Internet Explorer, the Windows browser, which is used by some 90% of all users. You need to decide for yourself.
Let's look at moving color into the <td> tags. Here we'll go from gray to white like this:
<td width="250" bgcolor="#c0c0c0">First Row,<br>
First Cell or Field</td>
<td width="250" bgcolor="#c0c0c0">First Row,<br>
Second Cell or Field</td>
</tr>
<tr>
<td width="250" bgcolor="#ffffff">Second Row,<br>
First Cell or Field</td>
<td width="250" bgcolor="#ffffff">Second Row,<br>
Second Cell or Field</td>
Will display our table like this:
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
Of course the <font> tag also works within each individual tab field. To set any font attribute within a table you need to define that font tag after each and every <td> tag. Here is an example of that where we have also turned the border off.
<td width="250" bgcolor="#c0c0c0"><font face="verdana">First Row,<br>
First Cell or Field</td>
<td width="250" bgcolor="#ffffff"><font face="times new roman">First Row,<br>
<font face="times new roman">Second Cell or Field</td>
</tr>
<tr>
<td width="250" bgcolor="#ffffff"><font face="times new roman">Second Row,<br>
First Cell or Field</td>
<td width="250" bgcolor="#c0c0c0"><font face="verdana">Second Row,<br>
Second Cell or Field</td>
First Row, First Cell or Field |
First Row, Second Cell or Field |
Second Row, First Cell or Field |
Second Row, Second Cell or Field |
OK, it's playtime. Here is an HTMLArea box for you to mess around with.
You Must Use IE Here ... NOT Firefox!
|
Daily SEO Tips eMail
SEO Blog
SEO Training
SEO Basics 101 eBook Learn All the Basics to SEO
|