SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Applying CSS to tables

    When applying CSS to tables, is it possible to apply CSS to a row and then override the style for an individual cell? I have a table where one or two cells in each row need a different bg color. I can't seem to make this happen and still maintain my 'zebra table' effect which I am applying at the row level.

    TIA.

  2. #2
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sure you can. We'd need to see your code to provide an accurate answer to your specific needs.
    Ryan Butler

    Midwest Web Design

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, here is one row:

    Code:
    <tr class='sd1'><td >16.20</td><td >15.40</td><td  class = 'gr'>12.50</td><td  class = 'gre'><b><i>21.00</i></b></td><td >8.90</td></tr>
    And here is the related CSS

    tr.sd1 td{
    background-color: #D7E1EE;
    color:rgb(45,0,0);
    font-size: 85&#37;;
    }

    td.gr{
    background-color: green;
    color:rgb(45,0,0);
    align: right;
    }

    td.gre {
    background-color: #B4B4B4;
    color:rgb(45,0,0);
    align: right
    }
    Last edited by snarky; Dec 31, 2007 at 13:54.

  4. #4
    SitePoint Wizard rbutler's Avatar
    Join Date
    Jul 2003
    Location
    Springfield, MO
    Posts
    1,867
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take out the descendant td tag from your first CSS rule.

    Code:
    tr.sd1 td{
    background-color: #D7E1EE;
    color:rgb(45,0,0);
    font-size: 85&#37;;
    }
    Ryan Butler

    Midwest Web Design

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you!

    That worked.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •