HTML Element Style How to - Float image to display images in a row








Question

We would like to know how to float image to display images in a row.

Answer


<!--from w  w  w.  jav  a2 s.c  o  m-->
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#images {
  width: 2000px;
}

#images img {
  width:  50px;
  height: 50px;
  float: left;
}
</style>
</head>
<body>
  <div id="images">
    <img src="http://www.java2s.com/style/download.png" /> 
    <img src="http://www.java2s.com/style/download.png" /> 
    <img src="http://www.java2s.com/style/download.png" /> 
    <img src="http://www.java2s.com/style/download.png" /> 
    <img src="http://www.java2s.com/style/download.png" /> 
    <img src="http://www.java2s.com/style/download.png" />
  </div>
</body>
</html>

The code above is rendered as follows: