SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    London, UK
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using css to change bg color of table cell

    Hi,

    I'm trying to use CSS to control the background color of a table cell but it isn't working.

    My CSS file contains:
    .steelygrey {
    background-color: #9793A7;
    }
    My table contains:
    <td align="center" valign="middle" style="steelygrey">
    <h1>Contact</h1>
    For more information etc etc
    </td>
    But the background color isn't working. The table cell is transparent.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    London, UK
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    D'oh!

    I'm an idiot. Using class instead of style now.

    Sorry everyone.

  3. #3
    100% Windoze-free earther's Avatar
    Join Date
    Feb 2003
    Location
    Linuxland
    Posts
    2,788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It can happen to anyone. I've even done it myself.

  4. #4
    The Prince burkul's Avatar
    Join Date
    May 2003
    Location
    Istanbul
    Posts
    744
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ISn't is better to use ;

    <td align="center" valign="middle" style="background-color:#9793A7">

    ?

  5. #5
    Object Not Found junjun's Avatar
    Join Date
    Mar 2002
    Location
    northern MI
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by burkul
    ISn't is better to use ;
    <td align="center" valign="middle" style="background-color:#9793A7">
    It depends. Usually you want to be able to use the same style on other elements on other pages. Creating a custom class and placing it in your css file makes more sense that way.

    Some would also argue that in the spirit of seperating style and content, the CSS rule naturally belongs in an external stylesheet, and thus removed from the html file.


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
  •