Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing background colour of each cell in a table

Status
Not open for further replies.

anto2

Programmer
Apr 4, 2001
29
IE
Is it possible to have each cell in a table a different colour.

Anthony.
 
yes, you could do this through css by having the following in the <head> of your page...

<style>
.red { background-color: #FF0000 }
.green { background-color: #00FF00 }
.blue { background-color: #0000FF }
</style>

...and then reference these styles like this...

<table>
<tr>
<td class=&quot;red&quot;>text</td>
<td class=&quot;green&quot;>text</td>
<td class=&quot;blue&quot;>text</td>
</tr>
</table>

...or you can just directly apply the colours to the cells...

<table>
<tr>
<td bgcolor=&quot;#FF0000&quot;>text</td>
<td bgcolor=&quot;#00FF00&quot;>text</td>
<td bgcolor=&quot;#0000FF&quot;>text</td>
</tr>
</table>

...if you intend to re-use colours you'd be better off using the css method.
 
Hi Secretsquirrel,

Thanks for your help
 
...and dont forget that you can place a background image in each if you wish, just needs a simply modification of the above codes!

É enzo@endamcg.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top