HTML Element Style How to - Align image next to each other








Question

We would like to know how to align image next to each other.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
div {<!--from www  .ja  va  2s .c o m-->
  float: left;
  margin: 10px;
}

p {
  margin-top: 5px;
}

img {
  width: 200px
}
</style>
</head>
<body>
  <div>
    <img src="http://www.java2s.com/style/download.png"  />
    <p>$17 000</p>
  </div>
  <div>
    <img src="http://www.java2s.com/style/download.png" />
    <p>$3500</p>
  </div>
</body>
</html>

The code above is rendered as follows: