Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text-align in Netscape doesn't work 1

Status
Not open for further replies.

davikokar

Technical User
May 13, 2004
523
IT
Hallo,
I have a table that contains other tables... When I want the nested table to be aligned right or left inside the cell I just put the text-align:right in the td tag and it will work for Explorer but not for Netscape. The text-align works in Netscape only if in the cell there is text but if there is another table it wont align it. Does someone know how to do it?

thankyou
 
Actually, it is Netscape that is behaving the way it should and IE that messes things up. According to the standards, the text-align property involves only text and not block elements. Block elements are positioned with margins on the element itself:
Code:
<table width="100%" border="1">
  <tr>
    <td [COLOR=blue][b]style="text-align: center;"[/b][/color]>
      <table width="100" border="1" [COLOR=red][b]style="margin-left: auto; margin-right: auto;"[/b][/color]>
        <tr>
          <td>This table is centered in Mozilla, Netscape, Opera and IE</td>
        </tr>
      </table>
    </td> 
  </tr>
</table>
<table width="100%" border="1">
  <tr>
    <td [COLOR=blue][b]style="text-align: right;"[/b][/color]>
      <table width="100" border="1" [COLOR=red][b]style="margin-left: auto; margin-right: 0;"[/b][/color]>
        <tr>
          <td>This table is right aligned in Mozilla, Netscape, Opera and IE</td>
        </tr>
      </table>
    </td> 
  </tr>
</table>
However, IE does not understand margins in a correct way, so you still have to employ the method you've been using. In the above example, everything will be aligned as expected in Mozilla, Netscape, Opera and IE. Blue represents what IE needs to align it properly and red what others (standards compliant) browsers need. Hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top