Click to See Complete Forum and Search --> : Need help with hyperlink color attributes


MarkE
01-07-2003, 08:37 PM
How do I change the color of an active link, visited link, and "normal" link properties of a particular hyperlink without editing the style sheet, but ONLY for that particular hyperlink? And is there a JavaScript mouseover attribute I can put in the <A> tag that will let me change the color of the link on mouseover? And is there any way I can do the same thing for onMouseOut, onMouseDown, onMouseUp, etc.?:confused: I appreciate your input.:p

Zach Elfers
01-07-2003, 09:45 PM
You could do:
<a href="link.html" style="color:red;">Text</a>

The only problem with this is that you can only edit the status that the link will always be. So if I put that as the color red, it will always be the color red. With JavaScript it is better, but it can take a lot of typing for one link:

<a href="link.html" style="color:red;" onMouseOver="this.style.color='blue';" onMouseOut="this.style.color='red';" onClick="this.style.color='green';">Text</a>

MarkE
01-07-2003, 10:01 PM
Thank you.

Stefan
01-08-2003, 09:39 AM
Originally posted by MarkE
change the color of an active link, visited link, and "normal" link properties of a particular hyperlink without editing the style sheet


May I ask why you don't want to do it with CSS? :confused:

JavaScript is a lot more likely to not work in browsers.

MarkE
01-09-2003, 09:05 PM
I see how you can do it with Javascript, but what if I also wanted to edit the Active Link attribute? Javascript cannot do this. Could I use something like this:
<a style="alink: 'red' vlink: 'blue'">Link</a> or <a style="a:visited='red' a:active='blue'">Link</a> or <a style="alink-color: 'red'>asfd</a> etc., etc., etc,... :(

Properties in a style sheet can also be used in a style attribute, right? I don't know what syntax to put into the style tag to edit the hover, active, and normal link colors.

Stefan
01-10-2003, 02:04 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>Example</title>
<style type="text/css" title="Default" media="screen">

.somename:link {color:red;}
.somename:visited {color:green;}
.somename:hover {color:yellow;}
.somename:active {color:blue;}

</style>
</head>
<body>

<p>
<a class="somename" href="">Link</a>

</body>
</html>

MarkE
01-13-2003, 08:29 PM
Is there a way using the "style" attribute in the <a> tag? Or maybe a hover attribute (if it exists)?

Stefan
01-14-2003, 04:45 PM
Originally posted by MarkE
Is there a way using the "style" attribute in the <a> tag? Or maybe a hover attribute (if it exists)?

No you cannot add eg hover states to your link inline.

However, there is no reason why you would want that. It just clutters up your markup.
Always keep your content and your styling/formating separete. It will make your pages a lot easier to manage.