Intermediate Web Publishing

Tables Revisited

table, tr, and td tags can have optional attributes, including:

width= value is either a number of pixels or a percentage of the current width
bgcolor=  value is the background color of the cell
<table width="90%" border="1" bgcolor="#FFCCFF">
 <tr align="center"> 
  <td width="50" bgcolor="#CCFFFF">50px</td>
  <td>This is the middle cell.</td>
  <td bgcolor="#FFFFCC" width="50"></td>
 </tr>
</table>
50 px This is the middle cell.

Unfortunately, MSIE and Netscape handle the above example differently. MSIE treats the "50" as a maximum; Netscape treats it as a preferred minimum. Netscape ignores background colors for empty cells; MSIE uses the table background color in the space between cells.

Moral: preview your pages in both browsers!


[up to series index] Next: Creating a web page with Word