Forum Moderators: open

Message Too Old, No Replies

wrapping text around an image

using the align attribute...

         

newnewbie1

10:19 am on Jul 7, 2003 (gmt 0)

10+ Year Member



Is it safe to use the "align" attribute on the IMG tag?

EXAMPLE:
<img src="images/clientpic3.jpg" width="195" height="270" align="right">

I'm trying to shove the image to the right and wrap the text around the left hand side. Not sure if it works in all browsers. And if I was using a stylesheet, how would I do this?

Thanks!

BlobFisk

10:32 am on Jul 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The above code will work, but is not valid HTML 4.01, as the align="" property is deprecated.

This is indeed possible with CSS, float your image in a div (right: 0), and you text will wrap around it!

tedster

10:32 am on Jul 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, it's safe -- but the tag is deprecated, so you're better off forming a stylesheet "habit" right off the bat.

img.r {
float:right;
}

and

<img class="r">

or inline:

<img style="float:right;">

The nice thing about stylesheets in this situation is that you have more control over the padding around the floated image. With old-style markup you had hspace and vspace, but they put an identical space on BOTH sides of the image. Now you can tailor it perfectly to the situation.

<edit>
I just relized that I had unneccesarily turned the img into a block element -- but float: can apply to ANY element.

So BlobFisk, your code certainly will work as well. And in fact, if you want to have a nice caption above or below the image, the div comes in very handy. But strictly speaking, you can float an inline element all on its own.
</edit>

killroy

11:15 am on Jul 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, when you flaot something it automatically becomes a block element, so technically you can't flaot an inline ;)))

SN

g1smd

8:28 pm on Jul 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



"Deprecated" simply means that the element is not included in the strict version of the specification, but is still included in the loose or transitional version. It also means that current browsers do still support the feature, but that future browsers might not support it; that future support is not guaranteed.