Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2007
    Location
    Bangalore, India
    Posts
    20
    Thanks
    4
    Thanked 1 Time in 1 Post

    Single class for normal text & link / hover

    I want to define a single style class with a pre-defined text color, lets say Black. But when I hyperlink a part of the text content, it should take a different property and yet another when I hover on the link.

    So far, what I have is

    .main_menu {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    font-size: 12pt;
    font-weight: normal;
    color: #000000;
    text-transform: none;
    }
    .main_menu:link {
    color: #CC0000;
    text-decoration: none;
    }
    .main_menu:visited {
    color: #CC0000;
    text-decoration: none;
    }
    .main_menu:hover {
    color: #0000FF;
    text-decoration: none;
    }


    What I want is:
    HomeAbout UsPortfolioContact

    Here, I don't have links on the bullet, hence they should be black. Since, I am going to hyperlink "Home", "About Us", etc., I want them to be colored Red and hover with Blue.

    How can I do this with just one class?

    Thanx,
    Sridhar

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Selector

    Specifiy the anchor element in the selectors to single out anchors:

    Code:
    .main_menu a {
    ...
    color: #F00;
    ...
    }
    
    .main_menu a:hover {
    ...
    color: #00F;
    ...
    }
    etc.
    Regards,
    Ronald.
    ronaldvanderwijden.com

  • #3
    New Coder
    Join Date
    Jul 2007
    Location
    Bangalore, India
    Posts
    20
    Thanks
    4
    Thanked 1 Time in 1 Post
    Thanx Ronald. It works.

    Sridhar


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •