Software Sue

Link to Simply Sue
Link to Sustainability Sue
location: software/markup/html/tables Skip navigation : Home  

HTML tables


Note. These pages have not been upgraded from HTML to XHTML

Tables Basics

Tables are constructed of rows, columns, and cells. A row may span several columns. A cell can span more than one row or column.

Here is a simple 3 x 2 table. It begins with a <TABLE> tag, which can be used to specify such attributes as the borders, alignment and width of the table. Each row is preceded by <TR> and followed by </TR>. Within each row, each cell begins with a table data entry tag, <td> and ends with </td>. The table ends with </TABLE>.

<table border="1" align = "center">
  <tr>
    <td>row 1, col. 1</td>
    <td>row 1, col. 2</td>
    <td>row 1, col. 3</td>
  </tr>
  <tr>
    <td>row 2, col. 1</td>
    <td>row 2, col. 2</td>
    <td>row 2, col. 3</td>
  </tr>
</table>

row 1, col. 1 row 1, col. 2 row 1, col. 3
row 2, col. 1 row 2, col. 2 row 2, col. 3

If you want to make a cell stretch across more than one column, use <TD COLSPAN=n>, where n is the number of columns. Similarly, use <TD ROWSPAN=n> to make a cell stretch down more than one row, as shown in the example below.

<table border="1" align = "center">
   <tr>
     <td rowspan="3"> 1</td>
     <td> 2</td>
     <td rowspan="2"> 3</td>
     <td> 4</td><td> 5</td>
     <td colspan = "3" rowspan="2"> 6</td>
   </tr>
   <tr>
     <td> 7</td> <td> 8</td> <td rowspan="2"> 9</td>
   </tr>
   <tr>
     <td> 10</td> <td colspan="2"> 11</td><td> 12</td><td> 13</td><td> 14</td>
   </tr>
</table>
1 2 3 4 5 6
7 8 9
1011121314

Don't use large tables, as the information will not display until the end table tag is reached.

Tables can look different in Netscape and Internet Explorer, so check your tables in as many browsers and versions as you can. Use an HTML checker such as BBEdit or Doctor HTML too.

Recent browsers understand tables, and ignore <BR> and <P> tags. Old browsers ignore tables, so add <BR> and <P> tags at the end of each cell, and use other standard HTML tags to make sure that old browsers show the information with some kind of formatting. Internet Explorer used to ignore line break tags in tables.

Adding headers, cellpadding and cellspacing, and nesting tables

Alignment, width, height

Arranging Information and Images

Organising Forms