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><div style=\"text-decoration: none; color:red; \">value3</td>

How can I make my display “value3”  without a  line-through?
Avatar of 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.
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:

    background-color: #F5FFFA;
    text-decoration: line-through;

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

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

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


Thanks a lot for the quick response