View Full Version : Internet Explorer 6.0 not obeying alignment rules

Jan 18th, 2007, 07:35 PM
I am trying to get Internet Explorer 6.0 to align an image center in a simple table but for the life of me, no matter how I rework the code, it always aligns left. Any idea what is wrong with this?

<table border="0" width="100%">
<td align="center" valign="top" width="200">
<a href="javascript:ShowBigImage(142934)" title="CD-ROM">
<img src="/images/CD-ROM.jpg" alt="CD-ROM" border="0" height="150" width="150" />
<br />
<a href="javascript:ShowBigImage(142934)" title="CD-ROM">See bigger image</a>

Jan 18th, 2007, 07:58 PM
It's possible your attribute to align it to the center (align="center") only aligns text to the center. (I don't know for sure.) Try adding "<center>" above your image and link and be sure to end it after your image and link. You could also add "<div align="center">" before your image and link.

Please note the element "<center></center>" only works in some browsers depending upon their standards.

Jan 18th, 2007, 07:58 PM
Im not much of a help because Im a newbie myself, but does it do the same on other browsers?

Jan 18th, 2007, 08:00 PM
I can answer that for him. No, the element "<td align="center"></td>" should work in Firefox and Opera. It just depends on the standards of the browser, in which IE does not follow W3 standards.

Jan 18th, 2007, 08:07 PM
IE sucks... I've been using Opera for quite some years and I never looked back. The best there is out there.

Jan 19th, 2007, 04:14 AM
How wide do you want the table to be?

On the one hand you have width="100%" for the table element while you have width="200" for the table cell. Since there is only one column it is unclear what you want.

Apparently this is enough to confuse IE. It centers the table cell content as if the cell is 200 pixels wide not taking into account that it may expand in width because of the width="100%" for the table.

To resolve things, either remove width="100%" for the <table> or remove width="200" for the <td>.

Jan 19th, 2007, 10:15 AM
<center> is obsolete and align="center" is deprecated and soon to be obsolete.

To centre text you use style="text-align:center;" and to centre block elements you use style="margin:0 auto;" or better yet move the entries into an external stylesheet where those elements that define the appearance of the page belong.