CSS File to Modify

  • Thread starter Thread starter JCO
  • Start date Start date
J

JCO

Is there a way to distinguish between links (w/hover) to another page versus
an internal BookMark (that I would like to be different?
 
The only way to do this would be to create classes, and assign the
appropriate class to internal and external links.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Because both types of links are exactly the same, they will react to common
CSS declarations the same way.

<a href="http://www.example.com">External Link</a>
<a href="#bookmark1">Bookmark Link</a>

There's no way to automagically use CSS to style them differently. (Let me
qualify that by saying there may be a way in the newest CSS spec, but it
won't be supported very well.)

You're going to have to create a new class and apply it to one of the link
types. So, assume you want to style the bookmark links you could create a
more specific style for bookmarks and then apply that to any bookmark link.
For example:

<html>
<head>
<style type="text/css">
a:link { color: #008000; }
a:link.bookmark { color: #f00; }
</style>
</head>
<body>
<p><a href="http://www.example.com">External Link</a></p>

<p><a href="#bookmark1" class="bookmark">Bookmark Link</a></p>
</body>
</html>

Note that you _need_ to combine the a:link.bookmark for it to apply to link
text.
 
Hi,
CSS isnt that smart - javascript could be. If you had 2 classes such as
a.internal{
color:red;
}
a.external{
color:green;
}
you could do something like
<script type="text/javascript">
function setLinks(){
var a = document.getElementsByTagName("A")
for(i=0;i<a.length;i++){
a.className=(a.indexOf(location.href)>-1)?"internal":"external";
}}
</script>
<body onload="setLinks()">

This will loop all the links and set boomarks to internal class and others
to external
 
If you don't mind formatting each link individually, you just select the
link and assign a class to it. It may a be a bit time-consuming, but you
will get the results you want, and it will be easier and faster than using
javascript.

Wally S
 
Thanks everybody for your response.
It dosen't appear that it is in the best interest to waste much time on
this.
Thanks again.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top