TMLP Online HTML Primer

Table Tags

Table Tag Definitions: <TABLE>

<TABLE> </TABLE> = Indicates the opening and closing of a table on the Web page.

The <TABLE> tag does have certain additional parameters that can be set to modify its appearance on the page.

<TABLE> Parameters

  • BORDER = Border drawn around individual cells and the outside.
  • BGCOLOR = Background color of all cells in the table. (6-digit hex number)
  • CELLSPACING = Spacing between cells (in pixels)
  • CELLPADDING = Spacing inside cells (in pixels)
  • ALIGN = Table position relative to the rest of the page (“left,” “center,” or “right”)
  • WIDTH = Total width of the page the table occupies. Can be a specific number (in pixels) or a percentage.

EXAMPLE: <TABLE BORDER=3 CELLPADDING=3 CELLSPACING=2 WIDTH=90%>

Table Tag Definitions: <TR>

<TR> </TR> = Indicates the opening and closing of a table row.

Like the <TABLE> tag pair, the <TR> tag pair has certain parameters that can be set to modify its contents.

  • BGCOLOR = Background color for all cells in the row.
  • VALIGN = Vertical alignment of the contents of all cells in the row. Can be set to “TOP,” “MIDDLE,” or “BOTTOM”

Example: <TR BGCOLOR=#000000 VALIGN=MIDDLE>

Table Tag Definitions: <TD>

<TD> </TD> = Indicates the opening and closing of a table Data element (cell). Any actual content in the table must appear within the <TD> </TD> tag pair.

Like the <TABLE> and <TR> tag pairs, the <TD> tag pair has certain parameters that can modify its contents.

  • ALIGN = Horizontal alignment of the contents
  • VALIGN = Vertical alignment of the contents
  • WIDTH = Width of the cell; can be a specific number or a percentage of the width of the table (not of the page itself!)
  • BGCOLOR = Background color of the cell.

Example: <TD ALIGN=“CENTER” WIDTH=25%>


Notes on Tables:

Because the contents of each <TD> </TD> tag pair is considered as a separate mini web page, it does NOT inherit the text formatting properties of anything outside of the table other than the general properties set for the overall page (i.e. in the <BODY> tag).

For example, if your text throughout the entire page is set to be shown in boldface, the <b> tag must also be listed inside each <TD> </TD> pair in which you want the text to appear in boldface.

Table Example:

Try plugging this into our "test.htm" file immediately after the <BODY BACKGROUND="image2.gif" BGCOLOR=#000000 TEXT=#00FF00 LINK=#FFFF00 VLINK=#FFFFFF ALINK=#FFCC00> tag:

<TABLE WIDTH=90% BORDER=3>
<TR BGCOLOR=#000000>
<TD WIDTH=25%>
Blah Blah Blah</TD>
<TD WIDTH=50% VALIGN=CENTER>
<B><I>BLAHBLAH</I></B></TD>
<TD WIDTH=25%>Blah</TD>
</TR>
<TR>
<TD>Blah Blaaah</TD>
<TD BGCOLOR=#FF0000>Blah</TD>
<TD>Blah Again</TD>
</TR></TABLE>

Now save the file and open it in your browser. You should see something like this:


Previous: Table Structure
Next: Frames Structure
Return To TMLP Online Residential Services