SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: css and td

Hybrid View

  1. #1
    SitePoint Evangelist jkh1978's Avatar
    Join Date
    May 2001
    Location
    Northern Virginia
    Posts
    445
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    css and td

    I have a table with class="test"

    in my css:

    .test td { background-color: #990000 }

    All my td have the correct background.

    How can I just change specific td to have a different color?

  2. #2
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use td.test { background-color: your color } in your css

    in the html of your selected table..
    <td class="test">

  3. #3
    Posts rarely lloydi's Avatar
    Join Date
    Jan 2002
    Location
    Swindon UK
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think what you're after is to avoid putting class="test" in each TD. Instead you want any TD that is a subset of a table that is of class "test" to apply that styling, am I right?

    In which case, your syntax was not quite right. This should do it though:

    TABLE.test TR TD {background:yellow;}

    alternatively you could use:

    .test > TD {background:yellow;}

    which means any TD that is a child element of something with a class of test, make it yellow!

    As usual, there is the small print about browser support to take in to account. First method more likely to work in greater number of browsers.
    Build Your Own Web Site the Right Way!
    A beginners' HTML/CSS book with web standards at its heart
    The Ultimate HTML Reference
    A complete reference, in glorious hardback


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
  •