"Class descendant Class" selector in CSS

Started by
4 comments, last by Servant of the Lord 11 years, 7 months ago
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?
Advertisement
Maybe
[source lang="css"]table.table_hidden > tr > td.table_left_column[/source]
? I believe it's something like that.

Beginner in Game Development?  Read here. And read here.

 

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?
</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. rolleyes.gif

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.
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.
Yes, the intention was that just "Stuff" is red. The reason why I needed ".table_hidden .table_left_column", was because I also have ".table_normal .table_left_column" and ".table_nice .table_left_column" - it's deliberate. Excellent catch though!

This topic is closed to new replies.

Advertisement