HTML Element Style How to - Float image in the same line left and right








Question

We would like to know how to float image in the same line left and right.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!--from  w  w  w.ja  v a  2 s .c  o m-->
<body>
  <div style="overflow: hidden; border: 2px black solid;">
    <img src="http://www.java2s.com/style/download.png" alt="Test Image 1" style="float: right;" /> 
    <img src="http://www.java2s.com/style/download.png" alt="Test Image 2" style="float: left;" />
    <p>Test Text</p>
  </div>
</body>
</html>

The code above is rendered as follows: