• 14
• 12
• 9
• 10
• 9

# "Class descendant Class" selector in CSS

This topic is 2038 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, I have two classes in CSS:

• .table_hidden
• .table_left_column

I can't get the CSS selector to work to match this.

The selector:
.table_hidden .table_left_column { vertical-align: top; color: red; }

The HTML:
<table class="table_hidden"> <tr><td align="center" colspan="2"><h2>Header</h2></td></tr> <tr><td class="table_left_column">Stuff</td><td>Text</td></tr> </table>

I'm expecting that, at the very least, the color of the text in the table should turn red - but it does not turn red.

Am I using the selector correctly?

##### Share on other sites
Maybe
[source lang="css"]table.table_hidden > tr > td.table_left_column[/source]
? I believe it's something like that. Edited by Alpha_ProgDes

##### Share on other sites
The selector looks correct.
Maybe you have another rule with a higher specificity that overwrites your selector?

What does firebug/whatever inspector you use show?

##### Share on other sites
</facepalm>

The CSS was working fine, but (being inline <style> CSS returned from a shortcode) WordPress was puking <p> and </p> every few lines, just to make sure the CSS wouldn't parse correctly.

Which is weird, because I am 85% sure I checked the generated HTML as one of the first things I did to debug it.

Thanks anyway, and sorry for wasting your time.

##### Share on other sites
I dont know if you intended for this to happen but what I get is Stuff is red the rest isn't. If you were going for it all to be red you are missing a comma in your css.
So instead of .table_hidden .table_left_column put a , inbetween them. If you intended on just stuff being red then why have .table_hidden in there at all? Just .table_left_column will do just fine. Edited by wicked357