Is there a way to apply a Class’ style to only ONE level of td tags?
<style>.MyClass td {border: solid 1px red;}</style> <table class='MyClass'> <tr> <td> THIS SHOULD HAVE RED BORDERS </td> <td> THIS SHOULD HAVE RED BORDERS <table><tr><td>THIS SHOULD NOT HAVE ANY</td></tr></table> </td> </tr> </table>
Yes*:
But! The ‘
>’ direct-child selector does not work in IE6. If you need to support that browser (which you probably do, alas), all you can do is select the inner element separately and un-set the style:*Note that the first example references a
tbodyelement not found in your HTML. It should have been in your HTML, but browsers are generally ok with leaving it out… they just add it in behind the scenes.