Chapter 9: Tables
index | previous | next

Spanning a Cell across Columns

With a table, it’s often necessary to straddle or span one cell across a few columns. For example, with multicolumn text, you could span a headline across the columns of text.

To span a cell across two columns:

  1. When you get to the point in which you need to define the cell that spans more than one column, type <TD.
  2. Type COLSPAN=n>, where n equals the number of columns the cell should span.
  3. Type the cell’s contents.
  4. Type </TD>.
  5. Complete the rest of the table. If you create a cell that spans 2 columns, you will need to define one less cell in that row. If you create a cell that spans 3 columns, you will define two less cells for the row. And so on.

Tip

  • Writing the HTML code for a table from scratch is, uh, challenging —especially when you start spanning columns and rows. It helps to sketch it out on paper first, as described on page 144, to get a handle on which information goes in which row and column. Or you can cheat and use a Web page editing program like FrontPage or PageMill to get started. You can always open the file and edit the HTML by hand later.
Figure 9.19 Notice that it was necessary to add the COLSPAN tag to the new header, the photo, and the caption since they all span across the two columns of text. The third bit of text (“Why is it so easy...”) is still separate and will appear below the table.
Figure 9.20 The three highlighted cells span two columns. The two columns of text are simply individual TD cells.
previous | next