align (HTML attribute)
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.
If the value were changed to "top",
the effect would be very different, as Figure 2 shows.
align is 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:
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
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
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.

