HTML Element Style How to - Make Image work as Link








Question

We would like to know how to make Image work as Link.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#logo {<!-- w w w.  j  ava2 s  .c  om-->
  width: 200px;
  height: 100px;
  margin: 0 auto;
  display: block;
}

#logo img {
  border: solid 3px #9966bb;
}

#logo img:hover {
  border: solid 3px #997777;
}
</style>
</head>
<body>
  <div id="logo">
    <a href=""> 
       <img src="http://www.java2s.com/style/download.png" class="cent_img"/>
    </a>
  </div>
</body>
</html>

The code above is rendered as follows: