To achieve this effect, simply change the image source to a 1x1 transparent gif.
This step is important in order to avoid displaying any default visuals in case of missing images or empty sources across various browsers. For example, Chrome may display a border around the image if it is not found.
By adjusting the background-image property, you can seamlessly switch between different images.
UPDATE
An alternative approach is to create image sprites and animate them by modifying the background-position attribute. Here's an example:
Suppose you have two images that are each 50px wide, and you want to show the second one when hovering over an element. Combine the images into one sprite file, then use the following CSS:
img { background: url(sprite.jpg) 0 0 no-repeat; }
img:hover { background: url(sprite.jpg) -50px 0 no-repeat; }