Link to home
Start Free TrialLog in
Avatar of loyaliser
loyaliserFlag for United States of America

asked on

over-riding css style for anchor tags

in a .css file i have defined anchor properties (hover, visited etc.)

how can i over-ride these settings in certain parts of an html page that uses this .css file?

e.g. use different hover colors etc.

thanks.
Avatar of Batalf
Batalf
Flag of United States of America image

You could use a class

.myclass{text-decoration:none;color:#ff0000;}
.myclass:hover{text-decoration:underline;color:#000000;}

ASKER CERTIFIED SOLUTION
Avatar of Batalf
Batalf
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Just specify a different class for each section of the page then you do not have to specify a class for each link:

<html>
<title> multi-links </title>
<head>
<style media="screen" type="text/css">
   .class1 a:link { color: blue }
   .class1 a:visited { color: blue }
   .class1 a:hover { color: blue}
   .class2 a:link { color: white }
   .class2 a:visited { color: white }
   .class2 a:hover { color: white }
</style>
</head>

<body>
<div class="class1">

... content for the first part of the page  ...
 
<div class="class2">

... content for the second part of the page

</div>
</font>
</body>
</html>
The div wrapped around the links for each section of the page will cause the links in that section to inherit the specification contained in that class.

Cd&
Avatar of loyaliser

ASKER

that's the ticket!

thanks...