Results 1 to 9 of 9

Thread: How to change webpage link colour?

  1. #1

    Default How to change webpage link colour?

    I know how to change the link colour of all the web pages by having it in the body tag but how do you set two link colours, example on the left side where the menu is, have the links be white, and on the main center where all the info is, have the links there be another colour?

    Is it done with some cascading style? If so can you please tell me how?

    Thanks!



    "Ouch"


  2. #2
    Hypnotising you crono_logical's Avatar
    Join Date
    May 2001
    Location
    Back in Time
    Posts
    9,313
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    Yeah, use CSS

    Say you give the A elements on the left a class of Mint, and the elements on the right a class of Farah, then in the style tag in the head, you'd write something like
    Code:
    .Mint a:link {color: #00ffff; /* plus other styles you want to set */ }
    .Mint a:visited { /* ... */ }
    .Mint a:hover { /* ... */ }
    .Mint a:active ( /* ... */ }
    .Farah a:link { /* ... */ }
    /*
    ...etc
    */
    to set up different styles for the A tag depending on their class. Replace the comments with useful CSS obviously I think that's how it works anyway


    EDIT: You can actually look at the source code for EoFF to see how it works too
    Problems playing downloaded videos? Try CCCP


  3. #3
    Last Exile Baloki's Avatar
    Join Date
    Sep 2003
    Location
    Dreaming a dream~
    Posts
    8,425
    Articles
    5
    Blog Entries
    2

    FFXIV Character

    Baloki Kyuu (Sargatanas)
    Contributions
    • Former Senior Site Staff

    Default

    Code:
    <style type="text/css">
    <!--
    a.mint:link {color: white}
    a.mint:hover {color: blue}
    -->
    </style>
    
    Archies code is very close, I give her that but you got the class bit the wrong way round which is an easy mistake.
    
    also the link will look like as follows:
    <a href="some address" class="mint">some link</a>
    FOA

  4. #4
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    I think crono_logical's example will let you do things like

    Code:
    <div class="Mint">
    <a href="blah">Hi</a>
    <a href="blah">Link</a>
    <a href="blah">Another</a>
    </div>
    So you can specify the class of the div (or span, if you want, or whatever is the parent of the a-tags), and all a-tag children of the div will use that style. The way Baloki put it, you'd have to put the class on the a-tags themselves, like


    Code:
    <a href="blah" class="mint">Hi</a>
    <a href="blah" class="mint">Link</a>
    <a href="blah" class="mint">Another</a>
    which is rather more typing, and harder to change later, but still a valid way to do things. I'd probably go with the first example, myself.

  5. #5

    Default

    It still didn't work.

    I tried both methods. I already put one style in there and I tried putting both codes inside this style, I also tried putting it in a seperate style tag and the colour of the main link is still white link the menu link.

    My code looks something like this:

    Code:
    <style type="text/css">  
        BODY { font-family: Arial, Helvetica, sans-serif; font-size: 12px; }
    a:hover{
    color:#C98A8E;
    }
    .Mint a:link {color:#515561}
    </style>
    and then I tried the div tag like Dr Unne said, and also putting the class inside the a href tag.
    Last edited by Sita Atis; 04-19-2004 at 04:41 PM.



    "Ouch"


  6. #6
    ORANGE Dr Unne's Avatar
    Join Date
    Dec 1999
    Posts
    7,394
    Articles
    1
    Contributions
    • Former Administrator
    • Former Developer
    • Former Tech Admin

    Default

    You have to replace < with < to make the code show up on the MB without being parsed, even if you put it in code tags. Blah. *kicks the VB*

    In CSS, there are different ways to specify what a style affects. A word by itself = just a tag. So
    Code:
    a {color:#f00}
    would affect all a-tags. A word starting with a period, as in .Mint, indicates a class. So
    Code:
    .blahrg {color:#f00}
    in the stylesheet would affect any tag with class="blahrg". (I don't know why everyone is using the word Mint. You can use any word for a class.) A word starting with a # indicates an id, so
    Code:
    #main {color:#f00}
    would affect any tag with an id="main".

    You can also combine them. When one word follows another word, it means "Any of the second which is a child of the first". So
    Code:
    a .menu {border:0px}
    would affect any tag which has class="menu", which is INSIDE an a-tag. So
    Code:
    <a href="blah"><img src="blah.jpg" class="menu"></a>
    would make that img tag have a property of border:0px;

    On the other hand, something like a.class means "an a-tag, with a class 'class'". That's probably what you want. So
    Code:
    a.blahg { color: #f00}
    affects all a-tags which have a class="blahg". Like
    Code:
    <a href="test" class="blahg">test</a>
    There are a great many rules, and I'm not sure I can go into them all. So yeah, try something like this.

    Code:
    <style type="text/css">
    a.blahg {
       color: #f00;
    }
    a.arf {
       color: #00f;
    }
    </style>
    Then

    Code:
    <a href="test1" class="blahg">link1</a>
    <a href="test2" class="arf>link2</a>
    Then the first link should be red and the second one should be blue.

  7. #7
    Hypnotising you crono_logical's Avatar
    Join Date
    May 2001
    Location
    Back in Time
    Posts
    9,313
    Contributions
    • Former Administrator
    • Former Cid's Knight

    Default

    I chose Mint and Farah because of #eoff I also closed an unclosed font tag in Sita's sig
    Problems playing downloaded videos? Try CCCP


  8. #8

    Join Date
    Nov 2003
    Location
    Sup
    Posts
    1,010
    Contributions
    • Former Administrator
    • Former Cid's Knight
    • Former Senior Site Staff

    Default

    Hi Sita <3
    goku

  9. #9

    Default

    That Dr Unne, such a great guy.

    thanks, it worked. Yeah I don't know that much about css

    Arche - Thanks, my sig skills suck

    Hi GokuKid749876



    "Ouch"


Posting Permissions

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