Change Link Font Colours and Overriding Them For Special Cases

Discussion in 'HTML' started by Hardeep Rakhra, Feb 9, 2004.

  1. Heya,

    I'm trying to use these css buttons on my site,

    http://www.meyerweb.com/eric/css/examples/plat-buttons.html

    however as soon as you have a default link colour specified by way of
    a:link, it overrides the colour values set for the css buttons in their
    class identifiers.

    I would have thought that applying a class to a element would have given
    the element those attributes and overridden any inherited of default ones.

    Any idea how i can resolve this?

    Hardeep.
    Hardeep Rakhra, Feb 9, 2004
    #1
    1. Advertising

  2. Hardeep Rakhra

    Els Guest

    Hardeep Rakhra wrote:
    > Heya,
    >
    > I'm trying to use these css buttons on my site,
    >
    > http://www.meyerweb.com/eric/css/examples/plat-buttons.html
    >
    > however as soon as you have a default link colour specified by way of
    > a:link, it overrides the colour values set for the css buttons in their
    > class identifiers.


    to have the colours you want, you should set the style for
    the a:link (and a:visited and a:hover of course if you want
    those colors changed too).
    So let's say the links are in a div like this:
    <div class="redlinks">
    <a href="home.html">

    You should set the style like this:
    div.redlinks a:link {color:red;}


    > I would have thought that applying a class to a element would have given
    > the element those attributes and overridden any inherited of default ones.


    Thought right, but the a:link is not the element you gave
    the style to.

    Or, also possible, you did put the a:link lower in the
    stylesheet than the div.redlinks a:link..
    The last style is the one that applies.

    When you are not sure what css styles mean and/or 'do', have
    a look at this page:
    http://penguin.theopalgroup.com/cgi-bin/css3explainer/selectoracle.py
    It translates css code into understandable english (or
    spanish, german, bulgarian)
    (and does a much better job than Babelfish :-D )

    --
    Els

    Mente humana é como pára-quedas; funciona melhor aberta.
    Els, Feb 9, 2004
    #2
    1. Advertising

  3. Els wrote:

    > Or, also possible, you did put the a:link lower in the
    > stylesheet than the div.redlinks a:link..
    > The last style is the one that applies.


    In this case, no. 'div.redlinks a:link' is more specific than 'a:link', so
    it doesn't matter which order they come in, 'div.redlinks a:link' will win
    out. Order only matters when the specificity of the selectors is equal.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
    Toby A Inkster, Feb 9, 2004
    #3
  4. Hardeep Rakhra

    Els Guest

    Toby A Inkster wrote:
    > Els wrote:
    >
    >>Or, also possible, you did put the a:link lower in the
    >>stylesheet than the div.redlinks a:link..
    >>The last style is the one that applies.

    >
    > In this case, no. 'div.redlinks a:link' is more specific than 'a:link', so
    > it doesn't matter which order they come in, 'div.redlinks a:link' will win
    > out. Order only matters when the specificity of the selectors is equal.


    Thanks for the correction :)

    --
    Els

    Mente humana é como pára-quedas; funciona melhor aberta.
    Els, Feb 9, 2004
    #4
  5. Els wrote:
    >
    > to have the colours you want, you should set the style for the a:link
    > (and a:visited and a:hover of course if you want those colors changed too).
    > So let's say the links are in a div like this:
    > <div class="redlinks">
    > <a href="home.html">
    >
    > You should set the style like this:
    > div.redlinks a:link {color:red;}
    >


    Thank you Els, that helped loads!

    Fixed the buttons but using spans and applying the button css to them
    and enclosing the lot in a link. Then used what you described above to
    remove the text decoration from all the buttons within the enclosing div.

    Thanks again.

    Hardeep.
    Hardeep Rakhra, Feb 9, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney

    Sentinel values for special cases

    Ben Finney, Oct 27, 2006, in forum: Python
    Replies:
    7
    Views:
    342
    Gabriel Genellina
    Oct 28, 2006
  2. Johny

    PIL and font colours.

    Johny, Apr 24, 2007, in forum: Python
    Replies:
    1
    Views:
    294
    Diez B. Roggisch
    Apr 24, 2007
  3. Johny

    PIL and font colours.

    Johny, Apr 25, 2007, in forum: Python
    Replies:
    0
    Views:
    259
    Johny
    Apr 25, 2007
  4. Aykut Canturk
    Replies:
    2
    Views:
    489
    Munna
    Jun 4, 2008
  5. mttc
    Replies:
    2
    Views:
    2,381
    Roedy Green
    Jul 3, 2009
Loading...

Share This Page