"highlight" on hover over text
diddi776
-
Mihawk Posted messages 4753 Status Contributor -
Mihawk Posted messages 4753 Status Contributor -
Bonjour,
I would like to know how to highlight text on hover with a color of my choice, like on the website "http://cuisine.journaldesfemmes.com"?
Configuration: Windows XP / Firefox 7.0.1
I would like to know how to highlight text on hover with a color of my choice, like on the website "http://cuisine.journaldesfemmes.com"?
Configuration: Windows XP / Firefox 7.0.1
5 answers
-
Hello,
This is a CSS property.
You need to wrap the text to be colored on hover in a tag.
For example:<span class="test">Here is some text to color on hover!</span>
Then, in the CSS:.test:hover { font-color:red; }
The :hover indicates that the action will only be performed when hovering over anything with the class "test".
I hope I answered your question; my CSS knowledge is starting to fade...
Dying seriously harms your health. -
Thank you for your responses,
To be more precise, I want each character on my site to be highlighted in a different color, for example like on the site I provided (http://cuisine.journaldesfemmes.com) it is "highlighted" in pink.
So I don't know if I can use in CSS: text-decoration and put overline like this:
.test {
text-decoration: overline;
}
to begin with -
A simple Google search and you're done :
*::selection { background:#cc2a00; color:#fff; } *::-moz-selection { background:#cc2a00; color:#fff; } *::-webkit-selection { background:#cc2a00; color:#fff; } -
Hello,
For that, you need to put an event in your code. -
Hi,
Unfortunately, there is no CSS property for "highlighting" as such. You need to wrap the text you want to highlight in a "span" that you will give a background color on hover, using the CSS pseudo-class "hover".
Here is an example of code to copy onto your computer, in a basic HTML file. It shows you how to use CSS combined with HTML to highlight a word when the mouse hovers over it.
<html> <head> <style> .surligneJaune:hover {background-color:yellow;} </style> </head> <body> <div> Here is a test text, and the following word is highlighted on hover: <span class="surligneJaune">dromedary</span>. </div> </body> </html>
--
Mihawk
"As long as we don't try, we won't know."