Jump to content
  • Advertisement
Sign in to follow this  
Servant of the Lord

"Class descendant Class" selector in CSS

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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. 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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!