Archive

Posts Tagged ‘align table’

Align a table in the middle of an HTML | XHTML page

August 26, 2009 Leave a comment

In the past it was common to align a table in the middle of a HTML page using the following code:

<div align="center">
<table>
<tr>
<td>
        Test String</td>
</tr>
</table>
</div>

However, this is no longer working as in the new XHTML standards “align” is not a valid attribute of

. So a better solution is to set the margin of the table to “auto”. You can delete the

as it is no longer needed for this purpose:

  <table style="margin: auto;">
    <tr>
      <td>
        Test String
      </td>
    </tr> 
  </table> 
Advertisements
Categories: ASP.NET Tags: , , ,