SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Hyperlinks and using different colours

  1. #1
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Ryde, Isle of Wight, UK
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Hyperlinks and using different colours

    I am currently working on a site for a client who has decided that they want different colour hyperlinks in different areas of the site currently it is set like this:
    Code CSS:
    a,  a:link {
      color: #99cc00;
      font-weight: bold;
      text-decoration: none;
    }
    /* Sets the style for visited links. */
    a:visited {
      color: #ff6699;
      font-weight: bold;
      text-decoration: none;
    }
    /* Sets the style for links on mouseover. */
    a:hover {
      color: #A1CBDE;
      text-decoration: underline;
    }
    /* Sets the style for a link that has focus. */
    a:focus {
      color: #A1CBDE;
    }
    /* Sets the style for a link that is being activated/clicked. */
    a:active {
      color: #ff9900;
    }
    /* Sets the style for unvisited links. */

    What I'm not sure about is how I can set each pages' hyperlink with a different set of colours, should I do this as a class or can I produce a rule like this? :-
    Code CSS:
    a1,  a1:link {
      color: #ff9900;
      font-weight: bold;
      text-decoration: none;
    }
    /* Sets the style for visited links. */
    a1:visited {
      color: #ff6699;
      font-weight: bold;
      text-decoration: none;
    }
    /* Sets the style for links on mouseover. */
    a1:hover {
      color: #99cc00;
      text-decoration: underline;
    }
    /* Sets the style for a link that has focus. */
    a1:focus {
      color: #A1CBDE;
    }
    /* Sets the style for a link that is being activated/clicked. */
    a1:active {
      color: #ff9900;
    }

    Just need some advice.

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    SitePoint Award Recipient Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    37,771
    Mentioned
    99 Post(s)
    Tagged
    3 Thread(s)
    Hi,

    There is no element called a1 so you can't use that approach

    Just use a class instead.

    Code:
    a.test,  a.test:link {etc.... }
    The CSS faq has a small tutorial on this that you might find useful.

    http://www.sitepoint.com/forums/show...64&postcount=2

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah in addition the different areas of the site are likley to already have different classes set to them so you could just do something like:

    .site-area-class a { }

    Rather than setting a class to each individual link, unless it is very specific. then you might need to add a class to the a's.

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2007
    Location
    Ryde, Isle of Wight, UK
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Guys,
    thanks for the info.
    Paul I decided to go with your suggested method, which worked perfectly.
    Many thanks for pointing me in the correct direction.

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
  •