Forum Moderators: open

Message Too Old, No Replies

align="right" in img tag works like float

is it OK to do it that way?

         

Purple Martin

2:32 am on Aug 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've noticed that simply putting an align="right" attribute in an img tag seems to have the same effect as floating it right. Is it just as OK to do it like this, or should I only be using float?

For example:
<p><img align="right" src="widgets.jpg">Here is some text that will be rendered to the left of the right-aligned image. If the text is long enough it'll wrap under the image.</p>

MonkeeSage

2:45 am on Aug 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Judging from the float specs (overview [w3.org], full [w3.org] ), I'd say they do the same thing. So if the markup you are using validates with the align attribute, I don't see any real advantage to floating it.

But I'm not a CSS purist...I'm more of a pragmatist...so I might have just commited a mortal sin to say that stylistic attributes in the markup are OK... ;)

Jordan

tedster

3:39 am on Aug 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



putting an align="right" attribute in an img tag

If you haven't already formed this habit, my advice is not to start. The align= attribute in HTML is deprecated, and it's not valid in HTML 4.01 strict.

So use CSS float:right; rules and be glad. CSS gives you more flexibility, especially around margins/padding for the images. The old vspace and hspace attributes (also deprecated) could only apply equal spacing on two sides of an image at the same time.

Purple Martin

4:00 am on Aug 26, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the info. Makes sense. I'll stick with floats.