HTML Element Style How to - Hover to hide an element








Question

We would like to know how to hover to hide an element.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.first:hover ~ .second {<!--from  ww w .jav a2  s.co m-->
  display: none;
}
</style>
</head>
<body>
  <div class="wrap">
    <div class="first">First div</div>
    <p>some other element...</p>
    <div class="second">Second div</div>
  </div>
</body>
</html>

The code above is rendered as follows: