How to change the image opacity on hover in CSS?

Asked 19-Jul-2021
Viewed 560 times

1 Answer


2

<!DOCTYPE html>

<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title></title>
    <style>
        img:hover {
            opacity: 0.5;
        }
    </style>
</head>
<body>
    <img src='heart.png' />
</body>
</html>