I would like some help with writing some CSS that can be used to express the following: If this element has a child element with a certain class attached, style it as follows.
What am trying to do is have a CSS class attached to a child element influence the styling on the parent - not the "usual" way of having a CSS class attached to a parent element influence the styling to be applied to the child.
For instance, take the following html:
<table>
<tr>
<td><span>One</span></td></li>
<td><span class="highlight">Two</span></td>
<td><span>Three</span></td>
</tr>
</table>
I would be trying to write some CSS to style a <td>
that finds itself with a child <span>
with the class "highlight"
a particular way - say, apply a red border to the <td>
FYI: I am aware of ways this can be achieved using jQuery dynamically using something like
$("span.highlight").parent().addClass("styling-class");
or
$("span.highlight").parent().css({"border": "1px #ff0000 solid"});
but lets say this solution does not render itself particularly easy to apply in my situation hence the reason am seeking a way to express it using CSS in my stylesheet file. I am neither a novice nor an expert in matters CSS. Is what am trying achievable?