Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » how to change the background color of cells in a table
Closed Thread
Old 06-06-2005, 09:37 PM   #1 (permalink)
 
True Techie

Join Date: Jan 2005

Posts: 123

Troubledyouth

Default how to change the background color of cells in a table

ok here is what i want to do.i am goin to have to cells side by side and i want each one to display a different color so what do i have to put in each <td> tag.i have put bgcolor and color and i can't remember how to do it
__________________
<img src=\"http://www.eraserinc.com/ims/pic.php?u=15tfnhP&i=56\">
<font size=1>Asus P5P800 Mobo, Intel P4 2.8Ghz,1Gb (2x512)Corsair Value Select Ram,BFG Tech 6800 OC,19\" Sony LCD monitor,Seagate 80GB Hard drive,Samsung DVD burner<and a crap power supply that just went out on me</font>
Troubledyouth is offline  
Old 06-06-2005, 09:39 PM   #2 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

I think you can just put <td bgcolor="#000000"> or whatever color in each one.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 06-06-2005, 09:44 PM   #3 (permalink)
 
True Techie

Join Date: Jan 2005

Posts: 123

Troubledyouth

Default

i tried that but it just stayed white.ill try again though
__________________
<img src=\"http://www.eraserinc.com/ims/pic.php?u=15tfnhP&i=56\">
<font size=1>Asus P5P800 Mobo, Intel P4 2.8Ghz,1Gb (2x512)Corsair Value Select Ram,BFG Tech 6800 OC,19\" Sony LCD monitor,Seagate 80GB Hard drive,Samsung DVD burner<and a crap power supply that just went out on me</font>
Troubledyouth is offline  
Old 06-07-2005, 09:55 AM   #4 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default

That should work perfectly.

<td bgcolor="#F1F1F1">

or if you are going to use a standardized color you can do this

<td bgcolor="red">
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
Old 06-08-2005, 05:52 AM   #5 (permalink)
 
Newb Techie

Join Date: Jun 2005

Posts: 18

warrior1981

Default

i think using the hexa code woud be appreciable whn compared to using it as Red, Green and Blue

the general coding however is from #000000 to #ffffff

more details hook on to http://www.islandnet.com/colors.html
warrior1981 is offline  
Old 06-14-2005, 12:45 PM   #6 (permalink)
 
Junior Techie

Join Date: Jul 2004

Posts: 57

kerriganm

Default

FYI, I've found some browsers seem to ignore the td bgcolor if you don't actually use the # in front of it. IE lets you get away with leaving it out, but they don't all.
kerriganm is offline  
Old 06-15-2005, 09:56 PM   #7 (permalink)
 
Super Techie

Join Date: Feb 2005

Posts: 262

jinexile

Default

bgcolor is improper Html, a throwback from pre-CSS times.

These days you want to keep your style and formating seperate.

Code:
<style type="text/css">
td {
Background-Color:#00ff00;
}
</style>

<table>
   <tr>
      <td>This background should be green</td>
   </tr>
</table>

__________________
AMD Athlon 64 3000+ (Overclocked to 3300+)
ASUS K8V-Deluxe
1GB PC3200 DDR
2x200GB Seagate SATA RAID 0
BFG 6800GT OC w\\128MB Ram
2x 19\" Samsung 930B LCDs
jinexile is offline  
Old 06-16-2005, 10:40 AM   #8 (permalink)
 
Junior Techie

Join Date: Jul 2004

Posts: 57

kerriganm

Default

Troubledyouth wanted each td a different color, so that approach wouldn't work for him. He could use inline styles:

<table>
<tr>
<td style="background:blue">blue cell</td>
<td style="background:green">green cell</td>
</tr>
<tr>
<td style="background:yellow">yellow cell</td>
<td style="background:red">red cell</td>
</tr>
</table>
kerriganm is offline  
Old 06-16-2005, 11:23 AM   #9 (permalink)
 
Super Techie

Join Date: Feb 2005

Posts: 262

jinexile

Default

oops mb.

He could also name them

He could also use ids like this:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
   <title></title>
   <style type="text/css">
   #row1 {
      Background-Color:#00FF00;
   }
   #row2 {
      Background-Color:#FF0000;
   }
   #row3 {
      Background-Color:#0000FF;
   }
   </style>
</head>
<body>
   <table>
      <tr>
         <td id="row1">This background should be green</td>
         <td id="row2">This background should be red</td>
         <td id="row3">This background should be blue</td>
      </tr>
   </table>
</body>
</html>

__________________
AMD Athlon 64 3000+ (Overclocked to 3300+)
ASUS K8V-Deluxe
1GB PC3200 DDR
2x200GB Seagate SATA RAID 0
BFG 6800GT OC w\\128MB Ram
2x 19\" Samsung 930B LCDs
jinexile is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On