View Full Version : Make text color change when mouse hovers

05-10-2007, 07:45 PM
Hi, I have a request to make the text color change when the mouse hovers over. I know how to do it on a link, but not on just plain text. Any help is much appreciated. Thanks!

05-10-2007, 08:40 PM
Maybe you came across an insufficiency of Internet Explorer 6 that only supports text color change in links but not on plain text (if done with CSS)?

Usually (in modern browsers) you can make any text/element change colors, for example:

span:hover, p:hover {color: red;}
#element_id:hover, .classname:hover {background-color: green;}

The first line makes all text in span and p elements red, the second line changes the background color of elements with a certain ID or class on mouse over.

05-10-2007, 08:54 PM
I apologize for not specifying - We currently do not use CSS, so I'm looking for it in HTML.

05-10-2007, 09:11 PM
Thereís no way to do it just with HTML. And I strongly recommend to make use of CSS. Itís not hard and itís the current way (has been for the last 7 years already).

Basically it works like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<style type="text/css">
a {color: green;}
a:hover {color: red;}
p:hover {color: blue;}
.important:hover {color: magenta;}

<p>Lorem <a href="#">ipsum</a> dolor sit <span class="important">amet</span>.</p>

05-10-2007, 09:18 PM
Thanks for the explanation. I wasn't sure if there was a way to do it at all with HTML.