CSS problem

Discussion in 'HTML' started by Jibba Jabba, Feb 17, 2004.

  1. Jibba Jabba

    Jibba Jabba Guest

    Ok looks like I've encountered another CSS problem, where I can't seem to
    override a previous CSS class.

    Look at the following source code. If the "tcat" class is taken off the
    <td> tag, then the "usrimg" class will work. Why can't class "usrimg"
    override the "tcat" class?



    <HTML><HEAD>
    <style type="text/css">
    <!--

    ..usrimg
    {
    }
    ..usrimg a:link
    {
    color: #0066CC;
    font: bold;
    }
    ..usrimg a:visited
    {
    color: #0066CC;
    font: bold;
    }
    ..usrimg a:hover, a:active
    {
    color: #FF0000;
    font: bold;
    }

    ..tcat
    {
    }
    ..tcat a:link
    {
    color: #FFFFFF;
    text-decoration: none;
    }
    ..tcat a:visited
    {
    color: #FFFFFF;
    text-decoration: none;
    }
    ..tcat a:hover, .tcat a:active
    {
    color: #FFFF66;
    text-decoration: underline;
    }
    </style>

    <body>
    <table cellpadding="6" cellspacing="1" border="0" width="800">
    <tr align="center">
    <td class="tcat" align="left">
    <div class="usrimg"><a href="df">dfsdf</a></div>
    </td>
    </tr>
    </table>
    </body>
    </html>
    Jibba Jabba, Feb 17, 2004
    #1
    1. Advertising

  2. Jibba Jabba

    Mark Parnell Guest

    On Mon, 16 Feb 2004 18:49:40 -0800, "Jibba Jabba"
    <> declared in alt.html:

    > Look at the following source code. If the "tcat" class is taken off the
    > <td> tag, then the "usrimg" class will work. Why can't class "usrimg"
    > override the "tcat" class?


    Because in your CSS file, .tcat is defined after .usrimg. They are both
    formed the same, so have the same specificity, therefore the last one
    takes precedence. Perhaps you should read up on the "cascading" part of
    CSS.

    http://www.w3.org/TR/REC-CSS2/cascade.html#cascade

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    Mark Parnell, Feb 17, 2004
    #2
    1. Advertising

  3. Jibba Jabba

    Jibba Jabba Guest

    > Because in your CSS file, .tcat is defined after .usrimg. They are both
    > formed the same, so have the same specificity, therefore the last one
    > takes precedence. Perhaps you should read up on the "cascading" part of
    > CSS.
    >
    > http://www.w3.org/TR/REC-CSS2/cascade.html#cascade


    Wow thanks for the clarification. Why was I under the impression that the
    first declared one took precedence? Stupid me.
    Jibba Jabba, Feb 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    4
    Views:
    687
    clintonG
    Dec 24, 2004
  2. tom watson

    print.css and screen.css

    tom watson, Sep 9, 2003, in forum: HTML
    Replies:
    1
    Views:
    448
    Jukka K. Korpela
    Sep 9, 2003
  3. Joshua Beall
    Replies:
    1
    Views:
    399
    Bertilo Wennergren
    Dec 10, 2003
  4. Noozer
    Replies:
    10
    Views:
    2,017
    Mitja
    Oct 13, 2004
  5. Titus A Ducksass - AKA broken-record
    Replies:
    6
    Views:
    630
    Titus A Ducksass - AKA broken-record
    Nov 15, 2004
Loading...

Share This Page