Reputation: 13210
Why cant i get background to change when i reference via a css style sheet, but works okay when done directly with color on inline style (i.e only columns 1 and 4 change their background color)
<table>
<tr>
<td bgcolor="#D6D6C2">Column 1</td>
<td class="releasetableheading">Column 2</td>
<td class=".releasetableheading">Column 3</td>
<td style="background-color:#D6D6C2">Column 4</td>
</tr>
</table>
CSS
.releasetableheading {
background-color=#D6D6C2;
}
See http://jsfiddle.net/ijabz/vnkqhz5h/ for full example
Upvotes: 0
Views: 371
Reputation: 476
Your syntax is off. Use colon instead of equals sign, and remove period from class declaration.
Updated Fiddle - http://jsfiddle.net/vnkqhz5h/1/
HTML:
<table>
<tr>
<td bgcolor="#D6D6C2">Column 1</td>
<td class="releasetableheading">Column 2</td>
<td class="releasetableheading">Column 3</td>
<td style="background-color:#D6D6C2">Column 4</td>
</tr>
</table>
CSS:
.releasetableheading {
background-color: #D6D6C2;
}
Note that bgcolor
is deprecated and should not be used and you should use classes, not inline styles whenever possible.
Upvotes: 3
Reputation: 4869
You should not use bgcolor attribute, it's not supported in HTML5. In HTML, you simply define your class that way :
<td class="myClass"></td>
And you can define a unique ID for an HTML element that way
<td id="myId"></td>
Then, in your CSS, the syntax has to be written that way:
.myClass{
background-color: #000;
}
#myId{
background-color: #fff;
}
Suffix for class is a dot (.) and for id is a hashtag (#).
You always write your property that way in CSS. "property: value".
Hope it helped !
Upvotes: 0