If you were to move your mouse over the links on learnfre.blogspot.com, you would notice that they are highlighted with a different colour. This article explains how you can achieve such mouseover or hover effects with links on your site.
Cascading Style Sheets (CSS) Code to Highlight Links on MouseOver
The default style in most browsers for a link can be described as follows:
The a:link portion basically indicates that the block following, enclosed in the curly brackets, is to be applied to links. Each line in the block gives a rule. The line beginning color tells the browser that the anchor text of the link is to be blue. The "transparent" value given to background-color means that whatever was in the background will be visible underneath the link text (including its existing colour). The text-decoration value of "underline" causes the browser to render the text with an underline.
To style the link when the mouse is hovering over it, simply add rules for a:hover. Take the following for example.
a:link {
color: blue ;
background-color: transparent ;
text-decoration: underline ;
}
The a:link portion basically indicates that the block following, enclosed in the curly brackets, is to be applied to links. Each line in the block gives a rule. The line beginning color tells the browser that the anchor text of the link is to be blue. The "transparent" value given to background-color means that whatever was in the background will be visible underneath the link text (including its existing colour). The text-decoration value of "underline" causes the browser to render the text with an underline.
To style the link when the mouse is hovering over it, simply add rules for a:hover. Take the following for example.
a:hover { color: black ; background-color: #def ; }
If you only want certain links to exhibit the mouseover highlighting effect, you can do it by applying those effects to certain classes.
a.specialeffects:hover {
color: black ;
background-color: #ff0 ;
}
<a class="specialeffects">this link will turn yellow</a>
That is, give links that you want the highlighting effect the "specialeffects" class.
You can of course name your classes anything you want, and not just "specialeffects". Whatever name you choose, make sure the name you use in your HTML link matches that in your CSS rules.
How to Remove the Underline from Links
If you don't want your links to be underlined, add the following to your rules:
text-decoration: none ;
a:link {
color: blue ;
background-color: transparent ;
text-decoration: none ;
}
Conclusion
That's it. Adding such mouseover effects to your links is fairly easy. Simply add the code given above, customize it to suit your site's design, and your links will now have a different appearance or colour scheme when the mouse moves over it. Feel Free to Ask Any Help About This Tutorial. :)
Post a Comment