HTML Element Style How to - Draw image's border when i mouse over it








Question

We would like to know how to draw image's border when i mouse over it.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--from   ww  w  .j  ava  2s. com-->
  border: 4px solid transparent;
}

img:hover {
  border: 4px solid lime;
}
</style>
</head>
<body>
  <img src="http://www.java2s.com/style/download.png" />
</body>
</html>

The code above is rendered as follows: