We help IT Professionals succeed at work.

Change style VISITED attribute inside div table

Janrow
Janrow asked
on
Medium Priority
1,244 Views
Last Modified: 2012-05-05
I need to change the text html link to underline, change text link color, and hover color when the page has been VISITED. I don't want to do this with CSS but with the style= statement inside a DIV directly in the html code on the page:

I prefer to use a table instead of CSS so I need the code inside the div.  This should only be for this one line, inside the div. I would also like to change the color of the link when it's been visited to something other than the default vlink on the page. For my purposes, white would be best for vlink. I know there are better ways to do this, but I'd prefer this way if possible.


<td>
<div style="what goes here?">
<a href="link-this-line">Ths text</a> should be underlined only when the page has been visited.
</div>
</td>

Open in new window

Comment
Watch Question

b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
Janrow,

The problem with not using CSS is Javascript doesn't know if the link was visited.  Javascript could do the change when the link is clicked, hovered and other events but it doesn't know if it was visited.  If visited is what you want you will need to stick with CSS.

CSS can change just that single line though.  Place the line in a span tag and assign a unique ID to the span or put the style tag in that span.  Let me know if you need help with the specifics of the style.

Let me know if you have any questions or need more information.

b0lsc0tt
Commented:
Janrow,

Your best bet is to define the CSS in a seperate class in the head of the document, like:
<head>
<style type="text/css">
a.visund:link {
	text-decoration: none;
         color: #0000FF;
}
a.visund:visited {
	text-decoration: underline;
	color: #FFFFFF;
}
a.visund:hover {
	text-decoration: none;
	color: #0000FF;
}
a.visund:active {
	text-decoration: none;
	color: #FF0000;
</style>
</head>
 
<body>
<table>
<tr>
<td>
<div>
<a href="your URL" class="visund">Ths text</a> should be underlined only when the page has been visited.
</div>
</td>
</tr>
</table>
</body>

Open in new window

Commented:
Janrow,

I know it's not exactly what you're looking for, but defining it as a seprate class won't effect your other tags, and you can reuse it in the document later if you want to.

I hope it is of some help.

Let me know if I can help a bit further.

Author

Commented:
Okay, I see what you mean. I searched for a couple hours to solve this.  You solved it in just mnutes. Perfect. I'll sleep tonight.

Thank you!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.