To change the text color on hover in CSS, you can use the :hover pseudo-class selector in conjunction with the color property. Here’s an example:
a:hover {
color: red;
}
This will change the text color of any <a> elements to red when the mouse pointer hovers over them.
You can also change the color of only a specific element by giving that element a class or ID and then targeting it specifically:
<p class="hover-color">Hover over me</p>
.hover-color:hover {
color: blue;
}
In this example, only the text within the <p> tag with the class of “hover-color” will change to blue on hover.
Also Read:
- How To Remove White Space Under An Image Using CSS
- What are Pseudo Elements And Pseudo Classes?
- Which CSS Property Is Used To Change The Face Of A Font?
- How To Change Background Opacity Without Affecting Text
- Change The Cursor Into A Hand When A User Hovers Over A List Item?
- How To Horizontally Center A DIV With CSS