Need help with hyperlink color attributes

admin

Administrator
Staff member
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<!--content-->You could do:<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"link.html" style="color:red;">Text</a><br />
<br />
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:<br />
<br />
<a href=http://www.webdeveloper.com/forum/archive/index.php/"link.html" style="color:red;" onMouseOver="this.style.color='blue';" onMouseOut="this.style.color='red';" onClick="this.style.color='green';">Text</a><!--content-->Thank you.<!--content-->Originally posted by MarkE <br />
change the color of an active link, visited link, and "normal" link properties of a particular hyperlink without editing the style sheet<br />
<br />
<br />
May I ask why you don't want to do it with CSS? :confused: <br />
<br />
JavaScript is a lot more likely to not work in browsers.<!--content-->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:<br />
<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,... :( <br />
<br />
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.<!--content--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><br />
<html><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br />
<meta http-equiv="Content-Script-Type" content="text/javascript"><br />
<meta http-equiv="Content-Style-Type" content="text/css"><br />
<title>Example</title><br />
<style type="text/css" title="Default" media="screen"><br />
<br />
.somename:link {color:red;}<br />
.somename:visited {color:green;}<br />
.somename:hover {color:yellow;}<br />
.somename:active {color:blue;}<br />
<br />
</style><br />
</head><br />
<body><br />
<br />
<p><br />
<a class="somename" href=http://www.webdeveloper.com/forum/archive/index.php/"">Link</a><br />
<br />
</body><br />
</html><!--content-->Is there a way using the "style" attribute in the <a> tag? Or maybe a hover attribute (if it exists)?<!--content-->Originally posted by MarkE <br />
Is there a way using the "style" attribute in the <a> tag? Or maybe a hover attribute (if it exists)? <br />
<br />
No you cannot add eg hover states to your link inline.<br />
<br />
However, there is no reason why you would want that. It just clutters up your markup.<br />
Always keep your content and your styling/formating separete. It will make your pages a lot easier to manage.<!--content-->
 
Back
Top