HTML Element Style How to - Hover image to show text








Question

We would like to know how to hover image to show text.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
span {<!--   w  w w .  ja  v a2 s.c om-->
  display: none;
}

img:hover+span {
  display: block;
}
</style>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png" />
  <span>Hello World!</span>
</body>
</html>

The code above is rendered as follows: