Results 1 to 5 of 5

Thread: Different CSS Links On The Same Page

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Different CSS Links On The Same Page

    Hi All,

    I have a sub-menu using links which I'm using this code for
    Code:
    a:link {
    	text-decoration: none;
    	color: #FFFFFF;
    }
    a:hover {
    	text-decoration: underline;
    }
    BUT my problem is I have other links on the page which I don't want to have these values I want them to have there own complete style... How can I do this?

  2. #2
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

  3. #3
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by blm126
    But how do I apply this to links? Don't they have to have the <a> tag?

  4. #4
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    It is the same conept, just change their demo to effect the a tag.

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by tomyknoker
    I have a sub-menu using links which I'm using this code for
    Code:
    a:link {
    	text-decoration: none;
    	color: #FFFFFF;
    }
    a:hover {
    	text-decoration: underline;
    }
    BUT my problem is I have other links on the page which I don't want to have these values I want them to have there own complete style... How can I do this?
    You need to introduce an ancestor into the selectors. That is, identify the submenu itself with either a class or id attribute (probably the former), and then prefix each rule with that class name. For example,

    Code:
    ul.menu a:link {
        /* ... */
    }
    HTML Code:
    <ul class="menu">
        <li><a href="/somewhere/">Somewhere</a></li>
        <!-- ... -->
    Mike

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
  •