Link to USGS home page
Internal USGS Access Only

Learning HTML - More Tables

Tables cells can be merged across both columns and rows. Note that badly constructed tables can cause a page containing them to fail to render at all!

Table Column Span Example
<table border="1" cellpadding="4">
  <tr>
    <th colspan="2">Title</th>
  </tr>

  <tr>
    <td>cell 1</td> <td>cell 2</td>
  </tr>

  <tr>
    <td>cell 3</td> <td>cell 4</td>
  </tr>
</table>
Title
cell 1 cell 2
cell 3 cell 4

Table Row Span Example
<table border="1" cellpadding="4">
  <tr>
    <th colspan="2">Title 1</th>
  </tr>

  <tr>
    <td rowspan="2">cell 1</td> <td>cell 2</td>
  </tr>

  <tr>
    <!--no cell--> <td>cell 3</td>
  </tr>
</table>
Title 1
cell 1 cell 2
cell 3

Table Caption Example
<table border="1" cellpadding="4">
<caption>This is a table caption</caption>
  <tr>
    <th colspan="2">Title 1</th>
  </tr>
  <tr>
    <td>cell 1</td>
    <td>cell 2</td>
  </tr>
</table>
This is a table caption
Title 1
cell 1 cell 2
Table Syntax
Attribute COLSPAN - span columns
Allowed in TD or TH tags. The boundaries between one or more cells within a row are removed, making the space act as a single cell.
Attribute ROWSPAN - span rows
Allowed in TD or TH tags. Cells between adjacent rows are merged to form a single tall cell. This can be confusing when creating tables by hand; cell definitions should be omitted for the cells that are joined by the span.
Element CAPTION - specifies captioning text for a table

There are many sophisticated formatting features associated with tables, including alignment, cell-by-cell border definitions, background colors and more.

slide 14


[up]
"Mastering a Web Site" online course
Created and maintained by Lorna Schmid and David Boldt.
http://water.usgs.gov/usgs/training/webmaster/html_tables2.html    
Last modified: Wed Oct 15 15:50:36 EDT 2003