SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast Bryce's Avatar
    Join Date
    Sep 2003
    Location
    Perth, Western Australia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS Selector Problem

    Hi there,

    I'm designing a site for uni, and I've encountered a problem - In two different div's (referenced by id's) I've got links. One div is #menu, one is #content.

    These are my selectors:

    #menu p a:link,a:visited
    #content p a:link,a:visited

    The problem is, IE is using only one of the selectors to format links (the first one) and this is causing problems with the colors. Is there something wrong with my syntax? Basically the html nesting is <div id="menu"><p>Random text and <a href="#">some links</a></p></div> in both instances.

    I don't mind switching to classes if it's going to make it work, but I'd prefer to use id's if possible.

    Any help would be greatly appreciated! Cheers guys.
    a distorted reality is now a necessity to be free...

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello

    I may be wrong, but I think if you remove the "p" part of the selector it should work.

    Code:
     #menu a:link,a:visited
      #content a:link,a:visited
    Hope it does.

    Later
    Johnny

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    [quote]
    #menu p a:link,a:visited
    #content p a:link,a:visited
    [quote]

    The last part of the selector is defining every a:visited on the page. It needs to be pre-fixed with its path just like the first part.
    Code:
    #menu p a:link,#menu p a:visited
    #content p a:link,#content p a:visited
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <style type="text/css">
    #menu p a:link,#menu p a:visited {color:red}
    #content p a:link,#content p a:visited{color:green}
    </style>
    </head>
    <body>
    <div id="menu">
      <p>Random text and <a href="#">some links</a></p>
    </div>
    <div id="content">
      <p>Random text and <a href="#">some links</a></p>
    </div>
    </body>
    </html>
    Hope that helps.

    Paul

  4. #4
    SitePoint Enthusiast Bryce's Avatar
    Join Date
    Sep 2003
    Location
    Perth, Western Australia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahh, thankyou! That fixed my problem indefinately Paul I must brush up on my defining of selectors...
    a distorted reality is now a necessity to be free...


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
  •