Change background color of specific table cell with CSS.

aimeeandbeatles

watermelon
Joined
Apr 5, 2007
Messages
20,112
This is for a school assignment where the teacher wants us to seperate the HTML from the CSS. However I am not sure how to change the background color of a specific table cell. I googled it and got stuff on rollovers and alternating colors. I tried it a few times and it didnt work. What should I do?:blush:
 
I'm definitely no CSS expert, but one way that works is by associating a class with the specific td element that you want to select in CSS, such as:

<td class="colorme">This is table data</td>

Then, in CSS you can use a class selector, like so:

.colorme {color:red};

I'm not sure if it's the prettiest way to do it, but it works.
 
Thats something like what I was looking for (I had tried it but somehow messed up cos it didnt work). I'll give it a try. Thanks :)
 
I got it. It was supposed to be background-color, not color. Thanks :D
 
Back
Top Bottom