HTML Element Style How to - Remove an extra space below the image inside a div








Question

We would like to know how to remove an extra space below the image inside a div.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.wrapper {<!--from   w  w w  .  j  ava  2s  . co  m-->
  width: 300px;
  margin: 10px;
  border: solid tomato;
}

.fix1 img {
  display: block;
}

.fix2 img {
  vertical-align: bottom;
}

.fix3 {
  line-height: 0;
}
</style>
</head>
<body>
  <div class="wrapper">
    <img src="http://www.java2s.com/style/download.png">
  </div>
  <div class="wrapper fix1">
    <img src="http://www.java2s.com/style/download.png">
  </div>
  <div class="wrapper fix2">
    <img
      src="http://www.java2s.com/style/download.png">
  </div>
  <div class="wrapper fix3">
    <img src="http://www.java2s.com/style/download.png">
  </div>
</body>
</html>

The code above is rendered as follows: