You are here:  NetStrider » Tutorials » HTMLRef » Tables » TABLE «
<TABLE> Command
Command Syntax:

<TABLE command parameters>
  <CAPTION>Caption</CAPTION>
  <TR command parameters>
    <TH command parameters>
      Header Cells
    </TH>
  </TR>
  <TR command parameters>
    <TD command parameters>
      Data Cells
    </TD>
  </TR>
</TABLE>

The <TABLE></TABLE> command tag pair enclose and define the global display characteristics for included table elements:
  • caption - <CAPTION>
  • table rows - <TR>
  • table headers - <TH>
  • table data cells - <TD>

Together these elements define a basic table.

See also:  <CAPTION>, <TD>, <TH>, <TR>.

Internet Explorer Specific Table Commands:

<TBODY>, <TFOOT>, <THEAD>.


Command Parameters:
align="left | right | center"

Defines the alignment of the table where:

  • left - aligns the table to the left margin of the available display space.
  • right - aligns the table to the right margin of the available display space.
  • center - aligns the table at the center of the available display space.
These parameters only work in the more recent versions of the Netscape and Internet Explorer browsers.  In order for alignment of tables to work in all browsers it is best to enclose the table within a <P> or a <CENTER> command element.

See also the valign parameter below.

border="pixels"

Defines width of the outer border of the table.  The border width is expressed as a pixel value.  A border value of 0 (the default) produces a table with no borders.

The border parameter forces borders on all cells within a table.  The outer border takes on the width specified.  All inner table borders are rendered by various browsers as one or two pixels wide, regardless.

The cellspacing parameter (below) is used to govern the gutter between individual table data cells.

The Internet Explorer browser also supports the frame and rules elements (below) which are also used to control border widths.

background="URL"

Defines the location of a background image for use globally within the table.  The image will tile behind the table and obscure any underlying page background color or image.  Obviously, this and the bgcolor parameter (below) are mutually exclusive.

bgcolor="color name | color value"

Defines the background color of the table expressed either as one of the named colors or as a hexadecimal color value.

bordercolor="color name | color value"
bordercolorlight="color name | color value"
bordercolordark="color name | color value"

Defines the color of the principal border or the highlighted and shaded sides, respectively, of the table external borders.  Color can be expressed either as one of the named colors or as a hexadecimal color value.

Only Internet Explorer browser supports these parameters.

cellpadding="pixels"

Defines the amount of white space or standoff between the margin of the table data cells and the included text and/or objects.  The standoff is expressed as a pixel value.

cellspacing="pixels"

Defines the amount of white space or gutter between table data cells.  The gutter is expressed as a pixel value.

frame="value"

Defines the characteristics of the table borders, if they are set.  Allowable values are:

  • above - displays the top external borders only
  • below - displays the bottom external borders only
  • box - displays all external borders as a box (default)
  • hsides - displays only the horizontal external borders
  • lhs - displays only the lefthand external borders
  • rhs - displays only the righthand external borders
  • void - removes all the external borders
  • vsides - displays only the vertical external borders

This parameter is used only in the Internet Explorer browser at present.

See also the rules parameter below.

height|width="% | pixels"

Defines the height and/or the width, respectively, of the table either as an absolute pixel value or as a percent of the available display width.

Using a percent allows the table to expand or contract depending on the user's screen resolution.

This is always safe with the width paramenter since available display width is always defined.

Using a percent in conjunction with the height parameter can cause curious display effects.  The amount of available vertical display space may not be known to the browser unless the table is confined within a predefined space.

Using absolute pixel values forces precise placement and display of table elements but can result in tables which may have regions which lie outside the viewing area.

rules="value"

Defines the characteristics of the table internal borders or rules, if they are set.  Allowable values are:

  • all - displays all the internal rules (default)
  • cols - displays vertical rules between columns only
  • groups - displays horizontal rules only between the <THEAD>, <TBODY> and <TFOOT> sections
  • rows - displays horizontal rules between rows only
  • none - supresses the display of all rules

This parameter is used only in the Internet Explorer browser at present.

See also the frame parameter above.

valign="top | bottom | center or middle"

Defines the vertical alignment of the table within the available display space.  This can be useful in setting the location of the table with respect to text which may wrap alonside the table.

Clearly, the table must be enclosed within a predefined vertical display space in order for this command parameter to work properly.

See also the align parameter above.

Example Table Layout:
<table align=center width=60% cellpadding=2 cellspacing=2 border=4> <caption> Table Caption </caption> <tr> <th> </th> <th>Column A</th> <th>Column B</th> </tr> <tr> <th>Row 1</th> <td>Cell A1 </td> <td>Cell B1 </td> </tr> <tr> <th>Row 2</th> <td>Cell A2 </td> <td>Cell B2 </td> </tr> <tr> <th>Row 3</th> <td>Cell A3 </td> <td>Cell B3 </td> </tr> </table> Yields -

Table Caption
Column A Column B
Row 1 Cell A1 Cell B1
Row 2 Cell A2 Cell B2
Row 3 Cell A3 Cell B3

Note that even without using any command parameters other than those within the basic table command, the browser is able to parse and display a reasonable table using defaults within the space available.

Return to the HTML Reference Guide Section S:Z

HTML Reference Guide Table of Contents.
Author: Randy D. Ralph.  In place February 27, 1999.  Copyright © 1999 NetStrider.  Presented as a public service.






Hosted by uCoz