How do I make image appear only when hovered?

I want the image of Brian May as a baby to sonly show when the list item “Brian May was born” is hovered. How do I do this?

Link to my code so far:

Hey there,

you can do this with JavaScript.

If you are already familiar with it,
you can do something like this:

  1. Add both images
  2. Make the baby image invisible/hidden
  3. When you hover over the desired line, make the baby image visible/unhidden and the adult image invisible/hidden
1 Like

I’m not that familiar with Javascript yet. Is there any way to do this in pure HTML and CSS? Or do you reccomend that I expand my knowledge about JavaScript before I attempt making something like this?

add this to your css

#img-born {

#born:hover + #img-born{
display: block;


@michicko It doesn’t seem to work. Am I doing it wrong?

My code:

You’re welcome. You should learn more about these selectors. it can be really useful. I’m still trying to figure them out. “+”, “>”, “&” and more…

1 Like

it does work. Check if you pasted it correctly.

1 Like

Sorry, i think you’re missing the id selector. It is supposed to be
#born:hover + #img-born” and not “#born:hover + img-born”

1 Like

Thank you so much! :grin:
I forgot to put the id selector, like you said. Your solution is exactly what I was looking for. Again, thank you!

1 Like