Ask Experts Questions for FREE Help !
Ask
    potski's Avatar
    potski Posts: 9, Reputation: 1
    New Member
     
    #1

    Apr 29, 2007, 09:28 PM
    Style Sheets in HTML
    Hello!

    I have two sets of links inside my web page:

    Link 1
    Link 2
    Link 3

    Link A
    Link B
    Link C



    When I put the mouse over Link 1-3, I'd like for it to change the font color to BLUE.
    a:hover{text-decoration: color: #4040FF;}


    For Link A-C, I'd like for it to change to RED when I put the mouse over it.
    a:hover{text-decoration: color: #FF0000;}



    I currently have this inside my <HEAD> tag:

    <style type="text/css">
    a{text-decoration: none;}
    a:hover{text-decoration: underline; color: #4040FF;}
    </style>


    ... but it affects the whole links inside my site. I want to be able to control the font color of
    Each of my links once the mouse is placed over it.


    If anyone can help me accomplish this, I'd really appreciate it.


    Thanks,

    Potski
    Northwind_Dagas's Avatar
    Northwind_Dagas Posts: 348, Reputation: 83
    Full Member
     
    #2

    Apr 30, 2007, 02:25 PM
    You need to use some classes to differentiate between the two types of links.


    Give the two link types some names. In this example, I will use "primary" for 1,2,3 and "secondary" for A,B,C.


    <HEAD> tag:

    <style type="text/css">
    a{text-decoration: none;}
    a:hover{text-decoration: underline; color: #4040FF;}
    a.primary:
    hover{text-decoration: color: #4040FF;}
    a.secondary:hover{text-decoration: color: #FF0000;}
    </style>

    Then, in your link codes:

    <a href="link1.html" class="primary">Link 1</a>
    <a href="link2.html" class="primary">Link 2</a>
    <a href="link3.html" class="primary">Link 3</a>

    <a href="linka.html" class="secondary">Link A</a>
    <a href="linkb.html" class="secodnary">Link B</a>
    <a href="linkc.html" class="secondary">Link C</a>


    Remember that classes are case sensitive so if you use caps in the head, use them in the links as well. Good luck!
    potski's Avatar
    potski Posts: 9, Reputation: 1
    New Member
     
    #3

    Apr 30, 2007, 09:46 PM
    Quote Originally Posted by Northwind_Dagas
    You need to use some classes to differentiate between the two types of links.


    Give the two link types some names. In this example, I will use "primary" for 1,2,3 and "secondary" for A,B,C.


    <HEAD> tag:

    <style type="text/css">
    a{text-decoration: none;}
    a:hover{text-decoration: underline; color: #4040FF;}
    a.primary:
    hover{text-decoration: color: #4040FF;}
    a.secondary:hover{text-decoration: color: #FF0000;}
    </style>

    Then, in your link codes:

    <a href="link1.html" class="primary">Link 1</a>
    <a href="link2.html" class="primary">Link 2</a>
    <a href="link3.html" class="primary">Link 3</a>

    <a href="linka.html" class="secondary">Link A</a>
    <a href="linkb.html" class="secodnary">Link B</a>
    <a href="linkc.html" class="secondary">Link C</a>


    Remember that classes are case sensitive so if you use caps in the head, use them in the links as well. Good luck!


    Hello. Thanks for replying. I tried the same codes you gave me, but it doesn't
    Seem to work. I don't know what I'm doing wrong. Below is my actual HTML coding:

    <html>

    <head>

    <style type="text/css">
    a{text-decoration: none;}
    a:hover{text-decoration: underline; color: #4040FF;}
    a.primary:hover{text-decoration: color: #808080;}
    a.secondary:hover{text-decoration: color: #FF0000;}
    </style>

    </head>

    <body link="green" vlink="green" alink="green">

    <a href="link1.html" class="primary">Link 1</a> <br>
    <a href="link2.html" class="primary">Link 2</a> <br>
    <a href="link3.html" class="primary">Link 3</a>

    <br><br><br>

    <a href="linka.html" class="secondary">Link A</a> <br>
    <a href="linkb.html" class="secondary">Link B</a> <br>
    <a href="linkc.html" class="secondary">Link C</a>

    </body>
    </html>

    ... it only follows the first hover line "a:hover{text-decoration: underline; color: #4040FF;}"
    I hope you can help me out and point out what I did wrong.


    Thanks,

    Potski
    Northwind_Dagas's Avatar
    Northwind_Dagas Posts: 348, Reputation: 83
    Full Member
     
    #4

    May 1, 2007, 09:07 PM
    It would seem that I carried over a mistake from your original code. In the following two lines:
    a.primary:hover{text-decoration: color: #808080;}
    a.secondary:hover{text-decoration: color: #FF0000;}
    There is a text-decoration: statement with no declaration. If you want a text decoration, such as underline, you must add it after the satement, as well as a semicolon. If you do not want anything other than the color change on hover, replace those two lines with these:
    a.primary:hover{color: #808080;}
    a.secondary:hover{color: #FF0000;}


    Good luck!
    potski's Avatar
    potski Posts: 9, Reputation: 1
    New Member
     
    #5

    May 1, 2007, 10:21 PM
    Quote Originally Posted by Northwind_Dagas
    It would seem that I carried over a mistake from your original code. In the folowing two lines:
    a.primary:hover{text-decoration: color: #808080;}
    a.secondary:hover{text-decoration: color: #FF0000;}
    There is a text-decoration: statement with no declaration. If you want a text decoration, such as underline, you must add it after the satement, as well as a semicolon. If you do not want anything other than the color change on hover, replace those two lines with these:
    a.primary:hover{color: #808080;}
    a.secondary:hover{color: #FF0000;}


    Good luck!


    It works now :) Thank you so much!
    You've been a great help!

    Regards,

    Potski

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Laminate Sheets for kitchen counter tops [ 3 Answers ]

Hi everyone, I was wondering if anyone knew where I can get laminate sheets to cover my existing laminate counter tops. Everywhere I have looked they sell the precut counters themselves, but they are standard sizes. I have one counter that is L shaped and very long and that's not standard size I...

Make new rough sheets soft [ 3 Answers ]

Does anyone know how to make new sheets soft? I bought some for my daughter and they are so rough, they hurt my face to lay on them-I realize the spending more money for higher quality but she just had to have the blue tiger striped ones :rolleyes: . I have washed and dried them about 3 times to...

9 foot sheets of drywall [ 5 Answers ]

Do they make drywall in 9 foot lengths for walls with a 9 foot ceiling?

Balance Sheets [ 5 Answers ]

Hello, I'm a treasurer for a club at the local college. I'm just finishing up my year so I can return the books to the advisor and I just have one problem. My Cash in Bank Doesn't equal my capital. Any Suggestions? Balance Sheet Assets Cash in Bank $3840.77 Total...

Balance sheets & Income Statements [ 2 Answers ]

I recently was asked to take a test for an interview on Balance sheets or Income Statement credit or debit. Please give me some examples for Balance Sheet and Income Statements being a credit or debit.


View more questions Search