Override CSS Link Color?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Al Franz

    Override CSS Link Color?

    Have a web site which uses a CSS file. There is one link which I would like
    to change the colors for the A:link, A:visited, and A:hover. Is there
    something I can put in the HTML code to override the CSS values?


  • Benjamin Niemann

    #2
    Re: Override CSS Link Color?

    Al Franz wrote:
    [color=blue]
    > Have a web site which uses a CSS file. There is one link which I would
    > like
    > to change the colors for the A:link, A:visited, and A:hover. Is there
    > something I can put in the HTML code to override the CSS values?[/color]

    These changes do not belong into the HTML code. The purpose of external CSS
    files is to keep such presentational stuff seperate from the document.

    The only thing you need to change in your HTML is adding a 'class' attribute
    to this special link, e.g.
    <a class="specialL ink" href="...">...</a>

    Then add rules in your CSS file like

    a.specialLink:l ink { color: white; }
    a.specialLink:v isited { color: black; }
    a.specialLink:h over { color: red; }

    --
    Benjamin Niemann
    Email: pink at odahoda dot de
    WWW: http://www.odahoda.de/

    Comment

    • Andy Dingley

      #3
      Re: Override CSS Link Color?

      On Mon, 20 Jun 2005 14:20:20 -0700, "Al Franz"
      <albert@nospam. netmation.com> wrote:
      [color=blue]
      > Is there something I can put in the HTML code to override the CSS values?[/color]

      The "C" in "CSS" stands for "Cascading" . The whole protocol is designed
      to allow this to be done easily.

      Use an in-line stylesheet like this:

      <html><head>

      < ... existing stuff .. >

      <style type="text/css" >

      a:link {
      }
      a:visited {
      }
      a:hover {
      }
      a:active {
      }

      </style>

      </head>

      More stuff....



      With CSS' default behaviour, you'll still use the existing external
      stylesheet, but you'll overwrite these specific rules with the internal
      stylesheet. This obviously only applies to a page which contains this
      internal stylesheet.

      If you don't want to do this to all links, start using a class attribute
      on them. If you want to do it to multiple pages, also consider using
      class, with an external stylesheet.

      The order of the pseudo-classes :hover etc. is significant.

      Go read a good book, like Lie & Bos, on CSS

      Comment

      Working...