Table of Contents
 Home
 About this Tutor
 Introduction
 HTML Editors
 Basic Code
 Utter Basics
 The Body Tag
 Headings
 The Font Tag
 Images
 Tables
 Tables Part Two
 Tables Part Three
 Nesting Commands
 Some Design Tips
 Meta Tags
 Web Hosts
 Uploading Your Site
 Copyright Issues
 HTML Mail Lists
 Future of HTML
 Marketing
 Style Sheets
 CSS and Text
 CSS and Fonts
 CSS and Cursors
 CSS and Backgrounds
 CGI
 CGI Scripts
 JavaScripts
 Affiliate Programs List
 Browsers
 Dang 404 Errors
 Color Chart One
 Color Safe Chart
 Color Chart Three
 Code Chart
 Arial Character Map
 Times Character Map
 Wing Ding Character Map

 Meta Tag Generator
 BBS Forum
 Contact Us
 Glossary
 SiteMap
This Site Has Been Rated:
Rating = 7.69By 180 Users
Please Vote Here:

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!


OK, it's </playtime> ... LOL!

A very handy way to positioning a block of type or image on a page is by nesting tables. Tables can be nested, or placed inside of each other and as many as you want. This page is a good example of nested tables. The entire page itself is set up in a table. Each of our little blocks of code are also set up as tables. But these other blocks are within the table that the entire page is set up within. It gives you great control over the placement of text, or images.

Mentioning text or images in the preceding paragraph brings to mind that you need to understand that tables can hold text, or images. You can have a table with nothing inside of it but an image. If that is the best way to get that image exactly where you want it, then go for it.

When nesting tables be sure that each new table ends itself out. The </table> must be present for each table. Further, each nested table must be ended before you can get yourself back to the previous table.

<table>
<tr>
<td>text</td>
<td><table border="1"><tr><td>nested text or image</td></tr></table></td>
</tr>
<tr>
<td>more text</td>
<td>more text here</td>
</table>

That should make some sense to you. The only way to get fluent with this coding is to do it. So now that you've read through the table section launch NoteTab and have a go at it. You can copy and paste if you wish, I don't blame you a bit, but do set up your own pages to experiment and view. It's really easy with NoteTab, just click on that icon to view your page!

OK, now check this out!

<table width="500" border="1" cellspacing="0" cellpadding="0">
<tr><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td></tr>
<tr><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td><td width="50" height="50" bgcolor="#000000"> &nbsp; </td><td width="50" height="50" bgcolor="#ff0000"> &nbsp; </td></tr>
</table>

Here's what it will look like:

                   
                   
                   
                   
                   
                   
                   
                   
                   
                   

Anyone for checkers?

To type out tables likes this, or for that matter any code at all that is the same, I use search and replace, or copy and paste. It's a lot easier! Matter of fact I write code with search and replace as often as possible. It's much easier than typing out page after page of code, and it's much more accurate also. For instance, let's say I am setting up a site and every page has a table for the main page, and a navigation column on the left, like this eBook has. If I get my thoughts together first, and then type each page with something like ...

$$TABLE AND NAVIGATION GO HERE$$

... at the start of every page, I can later do a search and replace through NoteTab and put the entire table and navigation into place with one fell swoop! By using something like the above replace string, with the $$ before and after it, I'm reasonably assured that the same text with $$ etc. won't appear somewhere else within my documents and I won't wind up with a table and navigation in the middle of a paragraph of content.

There are also ways to get all the headings, navigation column or anything else that shows up frequently throughout a site to automatically fill the page using a cgi script or a virtual include. We'll get into that later in this tutorial. Using a navigation bar as an example, you could have one file with all that information in it and call it out through a script to show up on every page. When you need to edit or update the navigation bar you only need do it to one file, not the entire site.


< >



Daily SEO Tips eMail
SEO Blog
SEO Training
SEO Basics 101 eBook
Learn All the Basics to SEO





© Copyright Night Train Web Productions Night Train Web Productions — All Rights Reserved
No Part of This Work May be Reproduced by any Means Without Prior Written Authorization
8153 / 051006 / 304089