Tables

Tables are used to organize the text and images in an HTML document. TABLEs requires start and end tags. Each table starts with an optional CAPTION followed by one or more TR elements defining table rows. Each row has one or more cells defined by TH or TD elements. Attributes for TABLE elements are WIDTH, ALIGN, BORDER, CELLSPACING and CELLPADDING.
An example of a table is:
  <TABLE BORDER=3 CELLSPACING=2 CELLPADDING=2 WIDTH="80%">
  <CAPTION ALIGN=bottom> ... table caption ... </CAPTION>
  <TR>
      <TD> first cell</TD> <TD> second cell</TD>
  </TR>
  <TR> ...</TR>
  ...
  </TABLE>

TABLE attributes are optional. By default, the table is rendered without a surrounding border. The table is sized automatically to fit the contents. You can also set the table width in pixels or percent using the WIDTH attribute. BORDER, CELLSPACING and CELLPADDING provide further control over the table's appearence. CELLSPACING specifies the amount of space inserted between individual cells in a table. CELLPADDING specifies the amount of space between the border of a cell and its contents. The ALIGN attribute can be used to position the table to the LEFT, CENTER or RIGHT. The CAPTION element is used for captions. These are rendered at the top or bottom of the table depending on the optional ALIGN attribute. Each table row is contained in a TR element. Table cells are defined by TD elements for data and TH elements for headers. TH and TD support several attributes: ALIGN and VALIGN for aligning cell content, ROWSPAN and COLSPAN for cells which span more than one row or column. A cell can contain a wide variety of other block and text level elements including form fields and other tables.

Some browsers also support different colors and backgrounds for the table and its cells using the BGCOLOR and BACKGROUND attributes
This is green This should display an image in the background
This is red this should display the color for the table

For more information see:



Click here to return to Wayne's World's homepage: arrowUp

Wayne Summers summers_wayne@ColumbusState.edu

last revised Aug. 7, 1996