Table Row Headers

As we've seen, each cell in a table can be a Table Data cell (<TD>). Another option for each cell in a table is to be a Table Header cell (<TH>). Both elements work exactly the same as each other.


<TH align="align_value"  rowspan="numer_of_rows"  colspan="number_of_columns>

       align = "left" or "center" or "right" or "justify"
       valign = "top" or "middle" or "bottom"
       rowspan = the number of Table Data cells to merge down a row
       colspan = the number of Table Data cells to merge across a column

Table Headers follow exactly the same format as Table Data cells.

So, for example, if we want to add Table Headers to the Connecticut and Massachusetts cells, enter a separate Table Row above the Table Data cells and enter two separate Table Headers, as follows (note that we've deleted the state names inside the Table Data cell)...

<TR>
<TH align="center">Connecticut
<TH align="center">Massachusetts

<TR>
<TD align="center" valign="top">Roger Sherman<BR>Samuel Huntington<BR>William Williams<BR>Oliver Wolcott

<TD align="center" valign="top">Samuel Adams<BR>John Adams<BR>Robert Treat Paine<BR>Elbridge Gerry<BR>John Hancock

The above HTML creates the following table cells:

Connecticut Massachusetts
Roger Sherman
Samuel Huntington
William Williams
Oliver Wolcott
Samuel Adams
John Adams
Robert Treat Paine
Elbridge Gerry
John Hancock

 

Just as you can merge Table Data cells to span multiple columns and rows, you can perform the same operation with Table Headers. So, for example, if you want to create a Table Header that spans multiple columns, you would specify the colspan attribute just as you specify colspan with the Table Data cell element (note that we've also set the TD Table Data cell alignment value to align="center"; and we removed the width="75%" attribute from the TABLE element):

<tr>
<th colspan="2" align="center">New Hampshire & Rhode Island

<tr>
<td align="center" valign="top">Josiah Bartlett<br>William Whipple<br>Matthew Thornton
<td align="center" valign="top" >Stephen Hopkins<br>William Ellery

The above HTML creates the following table cells:

New Hampshire & Rhode Island
Josiah Bartlett
William Whipple
Matthew Thornton
Stephen Hopkins
William Ellery

 

 

 

Copyright © 2001 Michael J. Doyle
All Rights Reserved.

Designed & Developed by Mike Doyle
using Macromedia Dreamweaver & CourseBuilder

See Mike's Training Schedule for
HTML, Dreamweaver, & CourseBuilder Courses


Email Mike Doyle