Flexible Tables Previous | Top | Next

 

Alignment rows

An alignment row contains images that force the browser to maintain minimum column sizes.
They also help browsers to render tables with colspans correctly.

 

No alignment row:

 

This is the red cell. This is the green cell.

I'm too flexible!

This is the gray cell.

<TABLE width="100%" border="0" cellspacing="0" cellpadding="0"> <TR> <TD width="120" bgcolor="#FF6666">This is the red cell.</TD> <TD width="120" bgcolor="#66FF66">This is the green cell.</TD> <TD width="100%" align=left valign=top bgcolor="#CCCCFF">I'm too flexible!</TD> <TD width="120" bgcolor="#666666">This is the gray cell.</TD> </TR> </TABLE>

 

With alignment row:
Note that the spacer.gif in the flexible column keeps the flexible column from shrinking below a minimum width.

 

This is the red cell. This is the green cell. I feel better now! This is the gray cell.

<TABLE width="100%" border="0" cellspacing="0" cellpadding="0"> <TR> <TD width="120" bgcolor="#FF6666">This is the red cell.</TD> <TD width="120" bgcolor="#66FF66">This is the green cell.</TD> <TD width="100%" align=left valign=top bgcolor="#CCCCFF">I feel better now!</TD> <TD width="120" bgcolor="#666666">This is the gray cell.</TD> </TR> <TR><!-- alignment row --> <TD><IMG src="img/spacer.gif" width="120" height="1"></TD> <TD><IMG src="img/spacer.gif" width="120" height="1"></TD> <TD><IMG src="img/spacer.gif" width="200" height="1"></TD> <TD><IMG src="img/spacer.gif" width="120" height="1"></TD> </TR> </TABLE>

 

Do you need an alignment row?

  • For simple tables (no colspan), every fixed-width column must contain a full-width image. If this condition is not met, add an alignment row.
  • For tables with colspans, you need either an explicit alignment row, or you need a row in your table that has similar properties.
  Previous | Top | Next