HTML Form How to - Align image button and input box








Question

We would like to know how to align image button and input box.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div.cont {<!--from  w w w .  j a v  a 2  s.  com-->
  text-align: center;
  line-height: 40px;
}

.cont img, .cont input {
  vertical-align: middle;
}
</style>
</head>
<body>
  <div class="cont">
    <a href="#" > 
       <img src="http://www.java2s.com/style/download.png" width="40" height="40" />
       <input type="text" value="" />
    </a>
  </div>
</body>
</html>

The code above is rendered as follows: