0
<img src="url" alt="a picture" style="width:42px;height:48px;background-color:#454141;">

I want to be able to change the background color of an image when i hover over the image. How can i do this built into the html code. I have tried hover:background-color:green;but this does not work.

It's for shopify email notifications system , so i cant create a new style sheet(easily)

Note , the image is designed as clear as to be able to select any color.

Lal
  • 14,726
  • 4
  • 45
  • 70
Barry Burke
  • 94
  • 2
  • 13

1 Answers1

0

An inline style attribute can only contain property declarations, that means you cannot use :hover this way.

You need to create a separate CSS file and write it as -

img:hover {
    /*Your code*/
}
Siddharth Thevaril
  • 3,722
  • 3
  • 35
  • 71