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 5 of 5

Thread: a href twice

  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts

    a href twice

    Hi, Is it possible to use two different a href styles within one html document.

    If so, can anyone give me an example ?

  • #2
    Senior Coder JamieR's Avatar
    Join Date
    Oct 2004
    Location
    United Kingdom
    Posts
    3,161
    Thanks
    0
    Thanked 5 Times in 5 Posts
    In CSS:

    Code:
    .one a {
    text-align:center;
    color:#000;
    }
    
    .two a {
    
    text-align:left;
    color:#FF0000;
    }
    Just have a different class for each different style.
    Last edited by JamieR; 12-14-2005 at 10:36 AM.

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    80
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, ive tried this:

    <html>
    <head>
    <title>Untitled</title>
    <style type="text/css">
    .one a {
    text-align:center;
    colour:#000;
    }

    .two a {

    text-align:left;
    color:#FF0000;
    }
    </style>

    </head>
    <body>
    <a href="uu" class="one">test 1</a>
    <a href="yy" class="two">test 2</a>


    </body>
    </html>

    but it doesnt seem to work ? Am i doing something wrong ?

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Code:
    <html>
    <head>
    <title>Untitled</title>
    <style type="text/css">
    a.one {
    color:#000;
    }
    
    a.two {
    color:#FF0000;
    }
    </style>
    
    </head>
    <body>
    <a href="uu" class="one">test 1</a>
    <a href="yy" class="two">test 2</a>
    
    
    </body>
    </html>
    The code weezel posted was if the link was inside of another element that had those classes, the way you did the html requires that the class be applied to the a in the CSS. Also CSS is all in the American english language.

  • #5
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts
    The code weezel posted was if the link was inside of another element that had those classes, the way you did the html requires that the class be applied to the a in the CSS. Also CSS is all in the American english language.
    ie, your hierarchies are the wrong way round. You need to either nest your <a> tags inside a div of the appropriate class, or change the css declaration to

    Code:
    <style type="text/css">
    .one a {
    color:#000;
    }
    
    .two a {
    color:#FF0000;
    }
    </style>


  •  

    Posting Permissions

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