Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorsnowrhythm
    • CommentTimeApr 18th 2006
     permalink
    this might be elementary to some of you, but I would appreciate some help with understanding it...I have this code for an "odd" table row background color. the "even" table row background has a different color that is actually the color set to the table. here is the code for the odd:

    tbody tr.odd td {
    background: #EFEFEF;
    color: #20613B;
    border: 2px solid #C1C1C1;
    }

    the first element in the html code for the table row is actually a <th> tag, and for some reason when i try to include it in the code like this:

    tbody tr.odd th td {
    background: #EFEFEF;
    color: #20613B;
    border: 2px solid #C1C1C1;
    }

    ...it makes all the <td>'s display the <table> background color....but the fist tag in the row (the <th> tag) is set to the #EFEFEF color.

    any ideas why it's doing this? this isn't so much of a "i can't get this to work" problem, because i've already found a solution for it. this is more of a "what makes this happen?" kind of thing. so what makes it happen?

    peace
    • CommentAuthorjohnsmith22
    • CommentTimeApr 18th 2006 edited
     permalink
    Hi,

    There's a simple answer to your question - "tbody tr.odd th td" should read "tbody tr.odd th" (that is, remove the last "td"). The TH tag is used instead of the TD tag, and not with it, so your CSS would actually be referencing all TDs which are inside THs, which is illegal according to the spec.

    Also, make sure that you actually mean "tr.odd" rather than "tr", otherwise this rule will only apply to code such as [td class="odd"][th] etc.

    Hope this helps :)
    • CommentAuthorsnowrhythm
    • CommentTimeApr 18th 2006
     permalink
    ah yes....that helps alot. i'm a bit new to this and i didn't quite understand that when you write elements down like that they are actually inheriting. that code was actually some free CSS and i was editing it for myself.

    thanks!
  1.  permalink
    Glad to see it helped. When you write elements after each other, it means that each element is contained within the previous one. If you want to write rules which apply to more than one element, then you can separate them using commas...
Add your comments
    Username Password
  • Format comments as (Help)