HTML Element Style How to - Show inner span when hover








Question

We would like to know how to show inner span when hover.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--   w ww.ja  v a  2  s. c  o m-->
  background: #ddd;
  float: left;
  width: 200px;
  height: 200px;
}

span {
  display: none;
}

div:hover span {
  display: block;
}
</style>
</head>
<body>
  <div>
    <span>show this on hover</span>
  </div>
</body>
</html>

The code above is rendered as follows: