JS Bug! Please Reload!


TABLES 101 - Lesson One

by Flo Deems

Current time is 08:16:08

In this lesson you will learn how to use the three basic table attributes.
You will construct a basic table of one row and one data cell.
You will also learn how to use a few attributes to make your simple table more interesting.

<TABLE></TABLE> - the container tag.
It must be closed at the end of everything you put into it.
You can also add other attributes. See further below.

<TR></TR> - Table Row (horizontal)
Close at the end of each row.
Usually no attributes added.

<TD></TD> - Table Data cell
Commonly referred to simply as cell.
Close each cell
The container for text and/or image.
Certain other attributes can be added here.

OPENING TAGS - the first tag of each pair above.
CLOSING TAGS - the 2nd tag of each pair above.

UPPER VS LOWER CASE: It is not necessary to capitalize any of the tags. Browsers prefer lower case these days (2009).
HTML 4.0 future versions will require lower case.

  • <table>
  • <tr>
  • <td>
  • Text, images go here.
  • </td>
  • </tr>
  • </table>

Use these 3 basic tags in the order outlined above.

DEFAULT SETTINGS - border, and cellspacing (in a future lesson), is one or two pixels wide for most browsers.
These defaults will show up in the table.



FRAMING AN IMAGE

Open a new file and c/c/p the code below and substitute your own image:

BORDER - Makes a visible boundary around the table.
Sized in pixels, 0 to many.
The "0" makes an invisible border.
Default on most browsers will be about 2 pixels; shows as a line around the table.

BGCOLOR - Colors the table. In this case, the border makes a black "frame" around the gif, which has its own white background.
Netscape users see a white border; Netscape does not recognize the bgcolor attribute when included in the table tag.

Copy the codes.
Experiment: Substitute your own border widths, including border="0," and bgcolor if you use a border of one pixel or larger.



FRAMING OR CONTAINING A TEXT SECTION

Instead of an image, you can put a text paragraph of any length in the data cell.
Cell length will grow to accomodate length of paragraph.

This is an example of putting text inside a table and using the table border attribute to create a reddish brown frame around the paragraph. I added a white background color to the Table Data cell. Then I specified the font size and color and typed the text. Then I used the closing tags in the reverse order that I used them above.

The code for the table above:

WIDTH: - Specify in pixel numbers for the table and/or the data cell, or the browser will configure the table's size minimally to contain the data that's put into it and no larger, as you see in the table above.

HEIGHT: - With width establshed, the height will grow to accomodate the length of the text.

CELLPADDING - space around text or image.
Add to the table tag: cellpaddng="10" - or whatever size space you'd like.
With images, the cellpadding attribute looks like the mat around a framed picture.

To put a margin around our text paragraph, the table below uses the cellpadding attribute:

This is an example of putting text inside a table and using the table border attribute to create a brownish frame around the paragraph. Then I added 15 pixels with the cellpadding attribute to give the text a border all around it. I added a white background color to the table data cell. Then I specified the font size and color.


So play around with this simple table format, changing each of the above attributes in turn until you understand what effect each will give you. You have one row with one data cell in it. When you think you understand this, we'll proceed to adding more data cells in the same row.

Lesson One Lesson Two Lesson Three
Row Tag Alignment for Table Cells
Tuesday 09th of February 2010 08:16:08 AM

See Flo's Other Tutes


by Tone By Tone Dot Net

Tandem Tooters
~ Arbor Hosting ~