Change color when mouse over a link in HTML

Defining CSS is definitely the proper way to tackle this issue, such as:


<style type="text/css">
a:link { color: #0000ff; }
a:visited { color: #00ff00; }
a:hover { color: #ff0000; }
a:active { color: #ff00ff; }
</style>

But if you just want to have a quick ad hoc solution, javacript come in handy:


<a style="color: black;" onmouseover="this.style.color='blue'" 
onmouseout="this.style.color='black'">change color</a>

Leave a comment