Skip to: content, navigation

by Ian Lloyd

align (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
Yes HTML 2
align=" { bottom | left | middle | right | top } "

Example

The align attribute for this img is set to "right":

<p><img src="giant-prawn.jpg" alt="The Giant Prawn at Ballina"
    align="right"/>Driving along, we spotted a giant prawn, so had to
    stop and take a closer look.</p>

Description

The align attribute is used to specify how the image sits on the page in relation to surrounding text and other elements. It is a fairly rudimentary attribute—and a very presentational one—that allows you to move an image to the right or left, with text wrapping around it accordingly (although without surrounding whitespace, which generally produces quite an ugly result). You can also alter the adjacent text alignment so that the first line of the text aligns with the top, middle, or bottom of the image.

The example markup shown with a right-aligned image would appear as shown in Figure 1.

Figure 1. A right-aligned image Right-aligned image

If the value were changed to "top", the effect would be very different, as Figure 2 shows.

Figure 2. An image for which align is set to "top" Image with align set to top

As the two examples show, the align attribute is no precision instrument when it comes to layout!

If an img is aligned "left" or "right", text will continue to wrap around it until it encounters either:

  • a br element with a clear attribute
  • any other element whose CSS clear property is set to "left", "right", or "both"

Value

"bottom", "left", "middle", "right", and "top" are the values that this attribute may take.

Nonstandard, proprietary attributes (which are still supported by Internet Explorer) that are acceptable include "absbottom", "absmiddle", "baseline", and "texttop".

Compatibility

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full

This attribute is now deprecated, and is highly presentational in its nature. The desired visual effects can all be achieved with CSS and, as such, this attribute shouldn’t be used—it’s presented here for informational purposes only.

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters