I am developing a css for printing in IE8, since i don’t have advanced css selectors( http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/ ) i concatenate them like this
I need to modifiy certain columns in a table(e.g. make 8th column red, 9th longer, 10 shorter… ecc)
The question is if i use
td+td+td{ /*instead of td:nth-child(3) on modern browsers*/
set something...
}
all the td from the 3rd one to the last one have that “set something”
so to fix it i have to do
td+td+td+td{
unset something
}
So i fixed it, but wondering why it acts like this?
+denotes adjacent selectors.td+td { }Generally means, if atdis preceded by anothertdthen apply certain ruleOne more example:
a + p {}Generally means, ifpcomes afterathen apply certain rule.So the style sheet you are using
td+td+tdwill apply the style to everytdafter the third elements. This might be a little complicated to be clear about. Lets see an example with sets of<td>Your rule
The above rule will apply to two different sets
First one, adjacent sibling from
<td>1</td>to<td>3</td>matchestd+td+tdSecond one, adjacent sibling from
<td>2</td>to<td>4</td>also matchestd+td+tdSo at the end, all the selectors from
<td>3</td>end up getting the styleTo cancel this effect, you reset the rule adding fourth selector on the style sheet.
i.e
Hope that explains it.
Further Reading