css and links color problem

Discussion in 'Programming' started by calisonder, Mar 28, 2007.

  1. #1
    i use this code to color my links and it works fine


    A:link {
    COLOR: #ffffff; TEXT-DECORATION: none
    }
    A:visited {
    COLOR: #ffffff; TEXT-DECORATION: none
    }
    A:active {
    COLOR: #ffffff; TEXT-DECORATION: none
    }
    A:hover {
    COLOR: #cccccc; TEXT-DECORATION: none
    }




    the problem is that i have some links that i want to be gray and others that i want to be yellow.

    How do I solve this problem?

    thanks in advance.
     
    calisonder, Mar 28, 2007 IP
  2. lslars31

    lslars31 Peon

    Messages:
    260
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    set up a separate class like this!

    a.classYellow:link {
    color: yellow;
    }

    a.classYellow:visited {
    color: yellow;
    }

    Then assign the class to your link like this:

    <a href="#" class="classYellow">Look, A Yellow Link!!!!</a>

    Hope this helps
     
    lslars31, Mar 28, 2007 IP
  3. calisonder

    calisonder Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks but how come the text size won't work when i do this

    a.classYellow:visited {
    color: yellow;
    font-size: 11px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    }
     
    calisonder, Mar 28, 2007 IP
  4. vegabond

    vegabond Shabu Anower

    Messages:
    1,656
    Likes Received:
    289
    Best Answers:
    0
    Trophy Points:
    240
    #4
    
    .yellow {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	color: #FFFF00;
    	font-size: 11px;
    }
    	.yellow a:link { 
    		color: #FFFF00; text-decoration: none;
    	}
    	.yellow a:visited {
    		color: #FFFF00; text-decoration: none;
    	}
    	.yellow a:hover {
    		color: #FFFF00; text-decoration: underline;
    	}
    
    Code (markup):
    You have to mention class in your url, ex:
    <a class="yellow" href="htp://">Yellow Link</a>
     
    vegabond, Mar 28, 2007 IP
  5. lslars31

    lslars31 Peon

    Messages:
    260
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Remember that is the visited link. Remember to change it for your regular link too.
     
    lslars31, Mar 28, 2007 IP
  6. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #6
    generally, you will want to class a wrapper of the anchor, not the anchor itself (for a more cross-browser solution)

    So if you had it in a ul/li you would do
    <ul class="nav">
    <li class="home"><a href="/">Home</a></li>
    <li class="contact"><a href="/contact/"></li>
    </ul>

    now you can do:
    ul.nav li.home a:link, ul.nav li.home a:visited, ul.nav li.home a:active { color:red; }
    ul.nav li.home a:hover { color:green; text-decoration:none; }
     
    ccoonen, Mar 28, 2007 IP
  7. lslars31

    lslars31 Peon

    Messages:
    260
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    which browsers dont work with the first way? I have been doing it that way for years while using ie5, then ie6, then firefox, safari, and a few based off those like camino and shiira. They all work for me.
     
    lslars31, Mar 28, 2007 IP
  8. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #8
    I remember seeing issues with this method in some browser, maybe IE4 or NS4?

    a.classYellow:link {

    where it can't detect the psuedo and class...
     
    ccoonen, Mar 28, 2007 IP
  9. lslars31

    lslars31 Peon

    Messages:
    260
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    oh I see. That makes sense then why I have never had those problems. I think it's safe to say however, that most people are using ie6 or above. As well as newer versions of ns4. Either way, it's only a little loss of color :D
     
    lslars31, Mar 29, 2007 IP
  10. calisonder

    calisonder Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    thanks everyone
     
    calisonder, Mar 29, 2007 IP