HTML Tables Tutorial

Page 19 - <td> bgcolor


Along with being able to specify the background color of a page and a table you can specify the background color of a <td>. A cell has the background color of its table, or, lacking one, the page itself. By setting the bgcolor of one cell you can override the default bgcolor of the table, as in the example. Like in the <body> tag and the <table> tag, the attribute is bgcolor.
<table border="1" bgcolor="#ccccff">
   <tr>
      <td>Cell #1</td>
      <td>Cell #2</td>
   </tr>
   <tr>
      <td>Cell #3</td>
      <td>Cell #4</td>
   </tr>
</table>
=
Cell #1 Cell #2
Cell #3 Cell #4

<table border="1" bgcolor="#ccccff">
   <tr>
      <td>Cell #1</td>
      <td bgcolor="#ffcccc">Cell #2</td>
   </tr>
   <tr>
      <td>Cell #3</td>
      <td>Cell #4</td>
   </tr>
</table>
=
Cell #1 Cell #2
Cell #3 Cell #4
 
 
MPF.com Site Map