Chapter 9: Tables
index | previous | next

Aligning a Cell’s Contents

By default, a cell’s contents are aligned two ways: horizontally to the left and vertically in the middle. To gain a little more control over the alignment of a cell’s contents, use the ALIGN and VALIGN tags.

To align the contents of cells horizontally:

  1. Place the cursor in the initial tag for the cell, row, or section, after the name of the tag but before the final >.
  2. If desired, type ALIGN=direction, where direction is left, center, or right.
  3. Type VALIGN=direction, where direction is either top, middle, bottom, or baseline.

Tips

  • You can align all of the cells in one or more rows or columns by inserting the ALIGN or VALIGN attribute in the appropriate tag (TR, THEAD, TFOOT, TBODY, COLGROUP, or COL).
  • The default value for ALIGN is left. The default for VALIGN is middle.
  • Officially, you can also justify a cell’s contents with both margins (ALIGN=justify) or align the contents with respect to any character you choose (ALIGN=char CHAR=x). Unfortunately, no browser I’ve seen supports either feature.
  • The baseline value aligns the contents of each cell with the baseline of the first line of text that it contains. Baseline is the same as top when there are several lines of text and no images. Baseline is the same as bottom when the cells contain both images and text. Only Netscape supports the baseline value.
Figure 9.23 You can add different alignment attributes to any cell in your table.
Figure 9.24 Compare the tops of the columns of text in this illustration with the ones in Figure 9.22. Now that I’ve aligned them all to the top, they look much better. Also note that I’ve aligned the caption to the right.
previous | next