Forum Moderators: open

Message Too Old, No Replies

Image flush right in table

         

Friend

5:22 pm on Jun 10, 2004 (gmt 0)

10+ Year Member



I just want an image to sit flush right in my table cell. I don't recall having this problem before. Right now I see about 2 pixels of white space to the right of my image.

I only see the problem in IE as well, Netscape shows the image aligned right just fine.

I get the same thing in a simplified case as well:

<table width="400" border="1" cellpadding="0" cellspacing="0">
<tr><td><img src="images/rightimage.jpg" border="0" width="214" height="166" alt="" align="right" />
</td></tr>
<table>

Does anyone know what's going on and if I can fix it?

Ouroboros

6:02 pm on Jun 10, 2004 (gmt 0)

10+ Year Member



I just tried the following with hspace="0" and it eliminated the space:
<table cellpadding="0" cellspacing="0" width="400" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>
<img align="right" src="image.gif" border="0" width="214" height="166" hspace="0" alt="" />
</td>
</tr>
</table>

Friend

6:38 pm on Jun 10, 2004 (gmt 0)

10+ Year Member



Thanks Ouroboros, that definitely worked. What is that tag? I've never seen it before and its not in dictionary.. So weird.

I also dropped the img into a div and it took care of the problem in IE.

Thanks for checking that out.

klogger

6:55 am on Jun 11, 2004 (gmt 0)

10+ Year Member



Oddly enougth in IE6 if you add a doctype of:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

the image also sits flush even without the hspace="0". It doesn't happen in IE5 or 5.5 though.

I hope Ouroboros doesn't mind me answering that hspace is for horizontal padding. All other content will sit that far away from the image on the left and right. There is also a vspace attribute for vertical spacing. I don't think they are valid tags past HTML 4.01 though where you should use:

style="padding-left:5px;padding-top:3px;"

to do the same job.

BlobFisk

9:21 am on Jun 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<table cellpadding="0" cellspacing="0" width="400" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>
<img align="right" src="image.gif" border="0" width="214" height="166" hspace="0" alt="" />
</td>
</tr>
</table>

There are a lot of deprecated tags in this code and depending on your DTD you may see different results.

As klogger pointed out CSS is the way to go here and it will allow the removal of all the deprecated tags.

HTH

BlobFisk

9:23 am on Jun 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<table cellpadding="0" cellspacing="0" width="400" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>
<img align="right" src="image.gif" border="0" width="214" height="166" hspace="0" alt="" />
</td>
</tr>
</table>

There are a lot of deprecated tags in this code and depending on your DTD you may see different results.

As klogger pointed out CSS is the way to go here and it will allow the removal of all the deprecated tags.

HTH