Jump to content

[SOLVED] A:link color problems


neoform

Recommended Posts

<style>
.class1, class1 a { color: blue; }
.class2, class2 a { color: green; }
</style>

<div class="class1">
   <a href="moo.html">This link shows up as blue</a>
   <a href="moo2.html" class="class2">This link shows up as blue even though it should be green.</a>
</div>

 

Anyone know how to get around this without resorting to applying classes to every <a> tag.. ? Like say I want to change the color of a single link while leaving default to all the others..

Link to comment
Share on other sites

ok, just noticed there was a bug in the css, but the color problem is there now.

 

<style>
.class1, .class1 a { color: blue; } /* forgot to put the dot in front of the second class name */
.class2, .class2 a { color: green; }
</style>

<div class="class1">
   <a href="moo.html">This link shows up as blue</a>
   <a href="moo2.html" class="class2">This link shows up as blue even though it should be green.</a>
</div>

 

any ideas?

Link to comment
Share on other sites

This is the correct CSS:

.class1 a{ color: blue; }
.class1 a.class2 { color: green; }
</style>

<div class="class1">
   <a href="moo.html">This link shows up as blue</a>
   <a href="moo2.html" class="class2">This link shows up as blue even though it should be green.</a>
</div>

Link to comment
Share on other sites

You can change the CSS to this:

/* all anchors in the document will have a defualt colour of blue */
a { color: blue; }
/* all anchors with the class of 'class2' a green colour - this will override the default colour */
a.class2 { color: green; }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.