Treehouse: Grow your CSS skills. Land your dream job.

table tr> td- does not give me the result I want

  • # January 3, 2012 at 11:51 am

    Hello everyone,
    I want to color the background of every first td in my table. using the code:

    table tr> td {
    background: lightgreen;

    The code colors all tds in the table. Can someone explain why? and also help me to produce the code that I am after.

    My code is below

    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"



    # January 3, 2012 at 12:17 pm

    I’m not really sure why this isn’t working. Instead, you could use first-child

    # January 3, 2012 at 12:18 pm

    Using table tr> td does not target the first cell, it targets all td’s that are direct children of tr (which, essentially, are all of them).

    You’ll have to use table tr td:first-child.

    # January 3, 2012 at 12:33 pm

    Thank you all so much four your help!!!!!

    # January 3, 2012 at 5:40 pm

    I may be rocking the boat here, but they are technically ‘headings’ for the table, so should you not be using

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.