System.Web.UI.HtmlControls Namespace HtmlTable Class
Sets or retrieves the alignment of the HtmlTable in relation to other elements on the Web page.
Inline |
<table align = 'left' | 'center' | 'right' ... > |
Script |
HtmlTable.Align [ = 'left' | 'center' | 'right' ] |
A string that specifies the horizontal alignment of the table with respect to other elements on the Web page.
The following table lists the values that can be used for this property.
Value |
Description |
left |
Aligns the HtmlTable on the left margin of the Web page. All subsequent text flows to the right of the object. |
center |
Aligns the HtmlTable in the horizontal middle of the Web page. |
right |
Aligns the HtmlTable on the right margin of the Web page.All subsequent text flows to the left of the object. |
The property is read/write with a default value of left.
Use the Align property to specify the alignment of the HtmlTable control in relation to other elements on the Web page.
NOTE: This property does not control the alignment of the contents in the cells of the HtmlTable control.
To control the alignment of contents of an individual cell, use the Align and VAlign properties of the HtmlTableCell class. You can also control the alignment of contents of the cells in an entire row by using the Align and VAlign properties of the HtmlTableRow class.
If you specify Left or Right alignment, other elements on the Web page will wrap to the right and left of the HtmlTable control, respectively. If you specify Center alignment, no wrapping occurs and other elements appear below the control.
The below snippet shows how to declaratively set the Align property of an HtmlTable control at design time.
<table cellspacing=1 width="92%" align="center" runat="server">
<tr>
<th>Table header</th></tr>
<tr>
<td>Table data</td></tr>
</table>
The following example demonstrates using the Align property to programmatically set the horizontal placement of the HtmlTable at run time.
Show me
HtmlTable Members