Log in

View Full Version : Different CSS Links On The Same Page



tomyknoker
09-22-2006, 01:21 AM
Hi All,

I have a sub-menu using links which I'm using this code for
a:link {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: underline;
}BUT my problem is I have other links on the page which I don't want to have these values I want them to have there own complete style... How can I do this?

blm126
09-22-2006, 02:00 AM
http://www.tizag.com/cssT/class.php Hope that helps

tomyknoker
09-22-2006, 02:30 AM
http://www.tizag.com/cssT/class.php Hope that helps
But how do I apply this to links? Don't they have to have the <a> tag?

blm126
09-22-2006, 11:16 AM
It is the same conept, just change their demo to effect the a tag.

mwinter
09-22-2006, 11:41 AM
I have a sub-menu using links which I'm using this code for
a:link {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: underline;
}BUT my problem is I have other links on the page which I don't want to have these values I want them to have there own complete style... How can I do this?
You need to introduce an ancestor into the selectors. That is, identify the submenu itself with either a class or id attribute (probably the former), and then prefix each rule with that class name. For example,



ul.menu a:link {
/* ... */
}



<ul class="menu">
<li><a href="/somewhere/">Somewhere</a></li>
<!-- ... -->

Mike