Images: Float

Use the CSS float property to let the image float. The image can float to the right, or to the left, of any text:

<img src="smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">
HTML file: Displayed by browser:
<!DOCTYPE html>
  <html>
    <body>

<p><strong>Float the image to the right:</strong></p>
<p><img src="images/smiley.gif" alt="Smiley face" style="float:right;width:42px;height:42px;">
This is a paragraph with a floating image. This image will float on the right side of this paragraph. A paragraph with a floating image.
</p>

<hr />

<p><strong>Float the image to the left:</strong></p>
<p><img src="images/smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px;">
This is a paragraph with a floating image. This image will float on the left side of this paragraph. A paragraph with a floating image.
</p>

    </body>
  </html>

Float the image to the right:

Smiley face This is a paragraph with a floating image. This image will float on the right side of this paragraph. A paragraph with a floating image.


Float the image to the left:

Smiley face This is a paragraph with a floating image. This image will float on the left side of this paragraph. A paragraph with a floating image.

Use the CSS float property rather than the align attribute. "Align" is deprecated in HTML 4, and HTML5 does not support it at all.

Back button Table of Contents Next button