Solved

over-riding css style for anchor tags

Posted on 2002-06-10
4
301 Views
Last Modified: 2012-05-04
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.
0
Comment
Question by:loyaliser
  • 2
4 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 7068311
You could use a class

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

0
 
LVL 32

Accepted Solution

by:
Batalf earned 50 total points
ID: 7068313
And of course use that class in some of your <a> tags

<a href="whatever" class="myClass"....
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 7068344
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&
0
 
LVL 1

Author Comment

by:loyaliser
ID: 7068370
that's the ticket!

thanks...
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Understanding mobile browsers 9 66
Convert html page to a php post email form automatically? 10 55
Call a function within the ASP code 4 12
innerHTML 7 23
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question