HTML Element Style How to - Align inline image inside div tag








Question

We would like to know how to align inline image inside div tag.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--from   w  w w.ja v a 2 s.  c om-->
  vertical-align: top;
}
</style>
</head>
<body>
  <div style="display: table; margin: 0 auto; margin-top: 10px">
    <input id="searchip" type="text" maxlength="30" autofocus="" size="50"
      name="textnew" style="height: 20px" /> 
    <img style="width: 20px;height: 20px"  src="http://www.java2s.com/style/download.png">
  </div>
</body>
</html>

The code above is rendered as follows: