Programer 5 days ago

How to change both div background color and inside content color on mouse hover?

I want CSS tricks to change background color and text color inside the div on mouse hover. i.e. when I hover anywhere inside the div the text color should change dynamically(without even hovering on text).


VKK 5 days ago

The CSS code below would change the background color and text color of all divs on hover. If you only want this applied to a specific div change div:hover to div#id-of-div:hover.

div:hover {

Zack Kirby 5 days ago

For modern browsers, you can use the following:

div:hover {
    background-color: red;
    color: white;

If you are looking to support older browsers, you'll need to use some javascript or jQuery to add a hover class to the div, then style the hover class.

Post Status

Asked in 5 days ago
Viewed 1,295 times
Voted 9
Answered 2 times


Leave an answer