This is an archived thread from the StopByte developer forum —
browse all archived threads.
StopByte is now a payments & ecommerce toolkit — check out our
free calculators.
I have <a /> hyperlinks in my HTML page for wish i want to replace (override) the highlight color when the mouse is over hyperlink i have a page as follows:
<html>
<head>
<title>My Sample HTML Page</title>
<!-- i define my css within my page, i tried using external .css file.
but yet the problem is not solved !!!
the aWithID Style, was my last attempt to solve this issue...
as i thought that the style is not linked that's why is not working
or it gets overriden by some other internal style. -->
<style>
a {
color:red;
}
#aWithID {
color:blue;
}
</style>
</head>
<body>
<div>
<p>Hello World!: My a html element highlight color is not working :(</p>
<a href="http://stopbyte.com">My Hyperlink #1</a>
<a href="http://stopbyte.com">My Hyperlink #2</a>
<a id="aWithID" href="http://stopbyte.com">My Hyperlink #3</a>
</div>
</body>
</html>
What did I do wrong above? How can i replace my <a /> hyperlink color when mouse is over the links? thanks
2 Likes
afree
(afree)
#2
You must apply your style to a:link, a:hover and a:active.
when you style a:link on it’s own that means the style used when the hyperlink is in its normal state.
when you style a:hover that means the style to be used when the hyperlink is mouse hovered.
when you style a:active means the style to be used when the hyperlink is already visited by user (usually it’s a darker blue).
apply your styles to those items instead of a. that should work.