Link to home
Create AccountLog in
Avatar of Steynsk
SteynskFlag for Netherlands

asked on

exclude one cell from style

Hi experts,

On my page I 'v got a table with a style that defines the style of a table row (<TR>)
In some cases I need to put a line-through effect on the text and this works fine for the complete line but now I'd like to exclude one cell (the last one in the row) from the line-through effect.

I've got this line in my css file causing the effect:

.oddafg {
    background-color: #F5FFFA;
    text-decoration: line-through;
}

This is my best try so far. The color works but the text-decoration does not work

<tr class= 'oddafg'>
<td>value1</td>
<td>value2</td>
<td><div style=\"text-decoration: none; color:red; \">value3</td>
</tr>

How can I make my display “value3”  without a  line-through?
Avatar of LZ1
LZ1
Flag of United States of America image

I wouldn't do it inline.  Make a separate CSS class for it and then add text-decoration:none !important;

Let us know
You could also use last-of-type, but it's not cross-browser compatible.  

http://reference.sitepoint.com/css/pseudoclass-lastoftype
you should try to style text through a tr.  it's not supported in all browsers as it shouldn't be cuz it's not a standard.  You should instead put classes on the tds themselves.  Below is my suggestion:

      .oddafg
      {
    background-color: #F5FFFA;
    text-decoration: line-through;
      }
      .newclass
      {
      color:red
      }


<table>
<tr>
<td class="oddafg">value1</td>
<td class="oddafg">value2</td>
<td class="newclass">value3</td>
</tr>
</table>
sorry that should say:
"You should NOT try to style text through a tr"
ASKER CERTIFIED SOLUTION
Avatar of SSupreme
SSupreme
Flag of Belarus image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SSupreme,

That is not cross browser compliant.
oh nvm, I didn't see the td in there.  Yes you can do it that way too.  Sorry.
Avatar of Steynsk

ASKER

Thanks a lot for the quick response