HTML Element Style How to - Wrap image in in a table cell








Question

We would like to know how to wrap image in in a table cell.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--from   w  ww  . ja  v a2 s  .  c  o  m-->
  vertical-align: top;
}

td {
  background-color: red;
  border: 1px solid blue;
  padding: 0;
  margin: 0;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td><img src="http://www.java2s.com/style/download.png"/></td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: