HTML Element Style How to - Remove space underneath inline-block image








Question

We would like to know how to remove space underneath inline-block image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#wrapper {<!-- www .j a  va 2 s  .co m-->
  background: green;
}

img {
  display: inline-block;
  line-height: 20px;
  margin: 0;
  vertical-align: top;
}
</style>
</head>
<body>
  <div id="wrapper">
    <img src="http://www.java2s.com/style/download.png">
  </div>
</body>
</html>

The code above is rendered as follows: