Coloured Underline

Discussion in 'CSS' started by gobbly2100, Aug 31, 2007.

  1. #1
    How can I make a coloured underline when I hover over links?

    I want to keep the text the same colour though.
     
    gobbly2100, Aug 31, 2007 IP
  2. Katy

    Katy Moderator Staff

    Messages:
    3,490
    Likes Received:
    513
    Best Answers:
    7
    Trophy Points:
    355
    #2
    border-bottom: 1px solid #000000;
     
    Katy, Aug 31, 2007 IP
  3. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think that is incorrect, I mean you could do it, but I wasn't aware that you were supposed to use the border style on inline links

    @gobbly
    You can't technically have a different colored underline (AFAIK) than the text unless you use an image.
    But to get an underline on hover do:
    <a class="link" href="http://site.com">Site.com</a>
    HTML:
    Css:
    
    a.link {
    text-decoration: none;
    }
    a.link:hover {
    text-decoration: underline;
    }
    
    Code (markup):
     
    bobby9101, Aug 31, 2007 IP
  4. HypertextFever

    HypertextFever Peon

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Yeah, you can do it. Put this in your CSS:

    
    a, a:visited {
      text-decoration:none;
    }
    a:hover {
      text-decoration:none;
      border-bottom:1px solid #ff9900;
    }
    
    Code (markup):
    Replace #ff9900 with your color.
     
    HypertextFever, Sep 1, 2007 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    You can also do it with an extra container using actual underline... though I suggest AGAINST this method since it is more HTML - there are situations where it's quite handy.
    
    <style type="text/css">
    a {
    	text-decoration:underline;
    	color:#F00;
    }
    
    a span {
    	color:#000;
    }
    </style>
    
    Code (markup):
    with:

    <a href="#"><span>Test</span></a>

    Works just fine.
     
    deathshadow, Sep 1, 2007 IP